index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view :style="{ minHeight: sys.windowHeight + 'px' }"
  3. :class="[$tm.vx.state().tmVuetify.black ? 'black' : ' ']">
  4. <tm-menubars title="衣物录入" :shadow="0" :showback="true"></tm-menubars>
  5. <div class="zhuti">
  6. <tm-sheet class="kuang" style="padding-bottom: 70px !important;">
  7. <image v-if="active==1" class="jindu" src="/static/img/49.png" mode="widthFix"></image>
  8. <image v-if="active==2" class="jindu" src="/static/img/50.png" mode="widthFix"></image>
  9. <image v-if="active==3" class="jindu" src="/static/img/51.png" mode="widthFix"></image>
  10. <view class="wenzi flex-between flex-center" style="margin-top: 10px;">
  11. <view>
  12. <text class="text-white text-size-m">衣物拍照</text>
  13. </view>
  14. <view>
  15. <text class="text-white text-size-m">确认衣物属性</text>
  16. </view>
  17. <view>
  18. <text class="text-white text-size-m">入库成功</text>
  19. </view>
  20. </view>
  21. <view v-if="active==1">
  22. <view class="mt-20 ml-15">
  23. <text class="text-white text-size-m">*衣物拍照实例图</text>
  24. </view>
  25. <image block class="zhanshi" mode="widthFix" src="/static/img/48.png"></image>
  26. <tm-button :round="24" class="mb-40" @click="paizhao()" block>拍照录入</tm-button>
  27. </view>
  28. <view v-if="active==2">
  29. <image block class="nicheng" mode="widthFix" :src="koutu"></image>
  30. <view class="you black mt-30">
  31. <!-- <tm-pickers v-for="item in arrbig" class="tan" :default-value.sync="item.choosevalue" rang-key="category_name" list="[]">
  32. <tm-input title="分类" placeholder="请选择分类" disabled :value="obTstrnew(category_danarr,'')" right-icon="icon-angle-right"></tm-input>
  33. </tm-pickers> -->
  34. <view v-for="(item,index) in arrbig">
  35. <tm-pickers v-if="item.type=='select'" @confirm="xuanze" :indexfu="item.name" :list="item.value">
  36. <tm-input :title="item.name" align="right" :placeholder="'请选择'+item.name" v-model="item.choosevalue" disabled right-icon="icon-angle-right"></tm-input>
  37. </tm-pickers>
  38. <tm-input v-if="item.type=='text' && item.name !='颜色'" :title="item.name" v-model="item.choosevalue" align="right"></tm-input>
  39. <view class="border-b-0 border-grey-darken-4-b-1 py-24 flex-between" v-if="item.name=='颜色'">
  40. <text class="text-size-n ">{{item.name}}</text>
  41. <view>
  42. <view class="seka" :style="{'backgroundColor':buttonColor}" @tap="showPickerColorPop"></view>
  43. <picker-color :isShow="showPickerColor" :bottom="bottomPickerColor" @callback='getPickerColor' />
  44. </view>
  45. </view>
  46. </view>
  47. <!-- <tm-listitem
  48. v-for="item in arrbig"
  49. :left-icon-size="80"
  50. value="打开"
  51. title="支付"
  52. label="微信和支付宝微信和支付宝微信和支付宝微信和支付宝"
  53. left-icon="https://cdn.roundicons.com/wp-content/uploads/2017/09/Lego-freebie-icon.png"
  54. show-left-icon
  55. ></tm-listitem> -->
  56. <!-- <tm-input :required="true" title="商品名称" v-model="reqData.goods_name" align="right"></tm-input> -->
  57. <!-- <tm-pickers class="tan" :default-value.sync="category_danarr" rang-key="category_name" :list="category_arr">
  58. <tm-input :required="true" title="分类" placeholder="请选择分类" :value="obTstr1(category_danarr,'category_name')" right-icon="icon-angle-right"></tm-input>
  59. </tm-pickers> -->
  60. <!-- <tm-pickers class="tan" :default-value.sync="role_danarr" rang-key="username" :list="role_arr">
  61. <tm-input title="所属成员" :required="true" placeholder="请选择所属成员" disabled :value="obTstr3(role_danarr)" right-icon="icon-angle-right"></tm-input>
  62. </tm-pickers> -->
  63. <!-- <tm-input title="年份" v-model="reqData.year" align="right"></tm-input>
  64. <tm-input title="颜色" v-model="reqData.color" align="right"></tm-input>
  65. <tm-pickers class="tan" :default-value.sync="size_danarr" rang-key="title" :list="size_arr">
  66. <tm-input title="尺码" placeholder="请选择尺码" disabled :value="obTstr2(size_danarr)" right-icon="icon-angle-right"></tm-input>
  67. </tm-pickers>
  68. <tm-input title="适用人群" v-model="reqData.type" align="right"></tm-input>
  69. <tm-input title="品牌" v-model="reqData.brand" align="right"></tm-input>
  70. <tm-input title="材料" v-model="reqData.science" align="right"></tm-input> -->
  71. </view>
  72. <tm-button :round="24" class="sao mb-40 mt-40" @click="chuangjianFun()" block>提交</tm-button>
  73. </view>
  74. <view v-if="active==3">
  75. <tm-translate ref="a_1" :auto="true" animation-name="zoomIn">
  76. <image block class="nicheng" mode="widthFix" src="/static/img/52.png"></image>
  77. </tm-translate>
  78. <view class="text-align-center mt-20">
  79. <text class="text-size-m text-white">衣物添加成功!</text>
  80. </view>
  81. <view class="text-align-center mb-40">
  82. <text class="text-size-m">您可以在我的衣柜中添加或删除衣物</text>
  83. </view>
  84. <view class="px-24">
  85. <tm-button @click="jixu()" :round="24" block class="mt-50 logincla">继续添加衣物</tm-button>
  86. <tm-button @click="quindex()" theme="primary" :round="24" block class="mt-30 quindex">进入衣柜</tm-button>
  87. </view>
  88. </view>
  89. </tm-sheet>
  90. </div>
  91. <!-- 弹出层消息 -->
  92. <tm-message ref="toast"></tm-message>
  93. </view>
  94. </template>
  95. <script>
  96. import{myRequest} from '@/api/request.js'
  97. import { pathToBase64, base64ToPath } from '@/js_sdk/mmmm-image-tools/index.js'
  98. import pickerColor from "@/components/helang-pickerColor/helang-pickerColor.vue"
  99. export default {
  100. components: {
  101. "picker-color":pickerColor,
  102. },
  103. data() {
  104. return {
  105. buttonColor:"#0099FF",
  106. showPickerColor:false,
  107. bottomPickerColor:0,
  108. arrbig:[],
  109. koutu:'/static/img/53.png',
  110. active:1,
  111. category_arr:[],
  112. category_danarr:[],
  113. size_arr:[
  114. {title:"S",id:1},
  115. {title:"M",id:2},
  116. {title:"L",id:3},
  117. {title:"XL",id:4},
  118. {title:"XXL",id:5},
  119. {title:"其他",id:6},
  120. ],
  121. size_danarr:[],
  122. role_arr:[],
  123. role_danarr:[],
  124. reqData:{
  125. goods_name:'',
  126. category_id:'',
  127. year:'',
  128. color:'',
  129. image:'',
  130. type:'',
  131. thumb:'',
  132. size:'',
  133. brand:'',
  134. science:'',
  135. role_id:'',
  136. fenlei:[]
  137. },
  138. };
  139. },
  140. onLoad() {
  141. },
  142. created() {
  143. this.sys = uni.getSystemInfoSync();
  144. this.getFl();
  145. this.getCY();
  146. this.jiaobenFun()
  147. },
  148. methods: {
  149. /* 显示获取颜色选择弹窗 */
  150. showPickerColorPop(){
  151. this.showPickerColor=true;
  152. },
  153. /* 获取颜色选择回调 */
  154. getPickerColor(color){
  155. /* 隐藏弹窗 */
  156. this.showPickerColor=false;
  157. /* 判断颜色值是否有效 */
  158. if(color){
  159. this.buttonColor=color;
  160. console.log('选择的颜色值是:'+color);
  161. }
  162. },
  163. showPickerColorPop(){
  164. this.showPickerColor=true;
  165. },
  166. xuanze(data){
  167. // var index=data[0].index;
  168. // this.arrbig[index].choosevalue=data[0].data;
  169. for(let i=0;i<this.arrbig.length;i++){
  170. if(this.arrbig[i].name==data[0].name){
  171. this.arrbig[i].choosevalue=data[0].data
  172. }
  173. }
  174. console.log(data)
  175. // console.log(this.arrbig)
  176. },
  177. getFl(){
  178. var that=this;
  179. myRequest({
  180. url: "/api/Category/list",
  181. method:'post',
  182. data:{}
  183. }).then(res => {
  184. console.log(res.data)
  185. if (res.data.code == 200) {
  186. this.category_arr=res.data.data;
  187. }else{
  188. that.category_arr=[];
  189. }
  190. })
  191. },
  192. getCY(){
  193. var that=this;
  194. myRequest({
  195. url: "/api/MemberInfo/getFamilyMember",
  196. method:'post',
  197. data:{family_id:uni.getStorageSync("family_id")}
  198. }).then(res => {
  199. if (res.data.code == 200) {
  200. that.role_arr=res.data.data;
  201. }else{
  202. that.role_arr=[];
  203. }
  204. })
  205. },
  206. obTstr1(o){
  207. if(Array.isArray(o)){
  208. if(o.length.length===0) return "";
  209. return o[0]?.category_name??""
  210. }
  211. return ''
  212. },
  213. obTstr2(o){
  214. if(Array.isArray(o)){
  215. if(o.length.length===0) return "";
  216. return o[0]?.title??""
  217. }
  218. return ''
  219. },
  220. obTstr3(o){
  221. if(Array.isArray(o)){
  222. if(o.length.length===0) return "";
  223. return o[0]?.username??""
  224. }
  225. return ''
  226. },
  227. jixu(){
  228. this.active=1;
  229. },
  230. quindex(){
  231. uni.switchTab({
  232. url: "/pages/wardrobe/index",
  233. })
  234. },
  235. paizhao(){
  236. var that=this;
  237. uni.chooseImage({ //uni官方api,用于选取本地图片
  238. count: 1, //默认9
  239. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  240. sourceType: ['album','camera'], //从相册选择
  241. success: function (res) {
  242. that.imgpath = res.tempFilePaths[0] //先获得本地文件的路径列表,存储到数组
  243. console.log(that.imgpath) //注意该api会将路径转换为blob格式
  244. // that.getBase64Image(that.imgpath);
  245. // 调脚本接口
  246. that.jiaobenFun()
  247. }
  248. })
  249. },
  250. obTstrnew(o){
  251. if(Array.isArray(o)){
  252. if(o.length.length===0) return "";
  253. return o[0]?.category_name??""
  254. }
  255. return ''
  256. },
  257. jiaobenFun(){
  258. var that=this;
  259. myRequest({
  260. url: "/api/Goods/selectScript",
  261. method:'post',
  262. data:that.reqData
  263. }).then(res => {
  264. if (res.data.code == 200) {
  265. // var arrbig=[
  266. // {name:"名称",value:"羽绒服",choosevalue:'',type:'text'},
  267. // {name:"颜色",value:"#b1b1b1",choosevalue:'',type:'text'},
  268. // {name:"尺码",value:["S","L","M"],choosevalue:'L',type:'select'},
  269. // {name:"材质",value:["牛仔","纯棉","羊毛"],choosevalue:'纯棉',type:'select'}
  270. // ]
  271. that.arrbig=res.data.data.parm;
  272. myRequest({
  273. url: "/api/Category/list",
  274. method:'post',
  275. data:that.reqData
  276. }).then(res => {
  277. if (res.data.code == 200) {
  278. var valuearr=[];
  279. for(let i=0;i<res.data.data.length;i++){
  280. valuearr.push(res.data.data[i].category_name)
  281. }
  282. var arrsmall=[{name:"分类",value:valuearr,choosevalue:'',type:'select',classid:''}];
  283. that.arrbig=arrsmall.concat(that.arrbig)
  284. that.fenlei=res.data.data;
  285. that.active=2;
  286. }else{
  287. }
  288. })
  289. }else{
  290. }
  291. })
  292. },
  293. getBase64Image(path){
  294. var that=this;
  295. console.log(" 开始转换")
  296. pathToBase64(path)
  297. .then(base64 => {
  298. that.shibie(base64)
  299. })
  300. .catch(error => {
  301. console.error(error)
  302. })
  303. },
  304. shibie(src){
  305. var that=this;
  306. // 抠图
  307. uni.request({
  308. url: 'https://objseg.market.alicloudapi.com/commonseg/rgba',
  309. method : "post",
  310. header: {
  311. 'Authorization':'APPCODE a4a922a41afa43a0bbca6c831a13bf43',
  312. "Content-Type":"application/json;charset=UTF-8"
  313. },
  314. data:{
  315. photo:src
  316. },
  317. success : function(data) {
  318. that.koutu=data.data.data.result;
  319. that.active=2;
  320. },
  321. error : function(e) {
  322. that.$refs.toast.show({model:'error',label:"网络异常,请重试"})
  323. }
  324. });
  325. },
  326. chuangjianFun(){
  327. var that=this;
  328. for(let i=0;i<that.arrbig.length;i++){
  329. if(that.arrbig[i].choosevalue==""){
  330. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  331. return
  332. }
  333. // 这里写循环放id
  334. }
  335. console.log(that.arrbig)
  336. // if(that.reqData.goods_name==""){
  337. // that.$refs.toast.show({model:'warn',label:'请输入商品名称'})
  338. // return
  339. // }
  340. // if(that.category_danarr.length==0){
  341. // that.$refs.toast.show({model:'warn',label:'请选择分类'})
  342. // return
  343. // }else{
  344. // that.reqData.category_id=that.category_danarr[0].id
  345. // }
  346. // if(that.role_danarr.length==0){
  347. // that.$refs.toast.show({model:'warn',label:'请选择成员'})
  348. // return
  349. // }else{
  350. // that.reqData.role_id=that.role_danarr[0].id
  351. // }
  352. // if(that.size_danarr.length!=0){
  353. // that.reqData.size=that.size_danarr[0].id
  354. // }
  355. // that.reqData.image=that.koutu;
  356. // that.reqData.thumb=that.koutu;
  357. // myRequest({
  358. // url: "/api/Goods/addGodds",
  359. // method:'post',
  360. // data:that.reqData
  361. // }).then(res => {
  362. // console.log(res.data)
  363. // if (res.data.code == 200) {
  364. // that.active=3;
  365. // }else{
  366. // that.$refs.toast.show({model:'error',label:res.data.msg})
  367. // }
  368. // })
  369. }
  370. },
  371. }
  372. </script>
  373. <style lang="scss">
  374. .zhanshi{
  375. width: 100%;
  376. margin: 0 auto;
  377. margin-top: 10px;
  378. margin-bottom: 40px;
  379. }
  380. /deep/ .tm-menubars .body{
  381. background-color: #1b1b1b !important;
  382. }
  383. /deep/ .kuang{margin:0 !important;padding: 14px !important;margin-bottom: 40px !important;}
  384. // /deep/ .kuang uni-button{background-color: #303440 !important;}
  385. .jindu{width: 90%;margin: 0 auto;display: block;}
  386. .wenzi{width: 94%;margin: 0 auto;}
  387. .nicheng{width: 60%;display: block;margin:0 auto;margin-top: 50px;}
  388. /deep/ .shuru .grey-darken-5{
  389. background-color: #0d0d0d!important;
  390. padding: 0px !important;
  391. }
  392. .shuru{border:1px solid #303030;border-radius: 10px;}
  393. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  394. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  395. .zuo image{width:60px;display: block;}
  396. .you{border:1px solid #303030;border-radius: 10px;padding:10px;}
  397. /deep/ .you .grey-darken-5{
  398. background-color: #0d0d0d!important;
  399. padding: 0px !important;
  400. }
  401. /deep/ .you .text-red{color: white;}
  402. /deep/ .tan .active{background-color: #AAAAAA !important;}
  403. /deep/ .tan .tm-poups .grey-darken-5{background-color: gray !important;}
  404. /deep/ .tan uni-input{text-align: right;}
  405. /deep/ .you .border-grey-darken-4-b-1 {
  406. border-bottom: solid 1px #313131 !important;
  407. }
  408. /deep/ .tm--badges{position: absolute;top: 0px;right:6px}
  409. .logincla{margin-top: 100px;}
  410. /deep/ .logincla .primary{background-color: #303440 !important;}
  411. /deep/ .quindex uni-button{background-color: #0A84FF !important;}
  412. .seka{width: 40px;height: 20px;}
  413. </style>