index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  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="index" :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.value" disabled 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:0,
  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. },
  137. };
  138. },
  139. onLoad() {
  140. },
  141. created() {
  142. this.sys = uni.getSystemInfoSync();
  143. this.getFl();
  144. this.getCY();
  145. this.jiaobenFun()
  146. },
  147. methods: {
  148. /* 显示获取颜色选择弹窗 */
  149. showPickerColorPop(){
  150. this.showPickerColor=true;
  151. },
  152. /* 获取颜色选择回调 */
  153. getPickerColor(color){
  154. /* 隐藏弹窗 */
  155. this.showPickerColor=false;
  156. /* 判断颜色值是否有效 */
  157. if(color){
  158. this.buttonColor=color;
  159. console.log('选择的颜色值是:'+color);
  160. }
  161. },
  162. showPickerColorPop(){
  163. this.showPickerColor=true;
  164. },
  165. xuanze(data){
  166. // var index=data[0].index;
  167. // this.arrbig[index].choosename=data[0].data;
  168. console.log(data)
  169. },
  170. getFl(){
  171. var that=this;
  172. myRequest({
  173. url: "/api/Category/list",
  174. method:'post',
  175. data:{}
  176. }).then(res => {
  177. console.log(res.data)
  178. if (res.data.code == 200) {
  179. this.category_arr=res.data.data;
  180. }else{
  181. that.category_arr=[];
  182. }
  183. })
  184. },
  185. getCY(){
  186. var that=this;
  187. myRequest({
  188. url: "/api/MemberInfo/getFamilyMember",
  189. method:'post',
  190. data:{family_id:uni.getStorageSync("family_id")}
  191. }).then(res => {
  192. if (res.data.code == 200) {
  193. that.role_arr=res.data.data;
  194. }else{
  195. that.role_arr=[];
  196. }
  197. })
  198. },
  199. obTstr1(o){
  200. if(Array.isArray(o)){
  201. if(o.length.length===0) return "";
  202. return o[0]?.category_name??""
  203. }
  204. return ''
  205. },
  206. obTstr2(o){
  207. if(Array.isArray(o)){
  208. if(o.length.length===0) return "";
  209. return o[0]?.title??""
  210. }
  211. return ''
  212. },
  213. obTstr3(o){
  214. if(Array.isArray(o)){
  215. if(o.length.length===0) return "";
  216. return o[0]?.username??""
  217. }
  218. return ''
  219. },
  220. jixu(){
  221. this.active=1;
  222. },
  223. quindex(){
  224. uni.switchTab({
  225. url: "/pages/wardrobe/index",
  226. })
  227. },
  228. paizhao(){
  229. var that=this;
  230. uni.chooseImage({ //uni官方api,用于选取本地图片
  231. count: 1, //默认9
  232. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  233. sourceType: ['album','camera'], //从相册选择
  234. success: function (res) {
  235. that.imgpath = res.tempFilePaths[0] //先获得本地文件的路径列表,存储到数组
  236. console.log(that.imgpath) //注意该api会将路径转换为blob格式
  237. // that.getBase64Image(that.imgpath);
  238. // 调脚本接口
  239. that.jiaobenFun()
  240. }
  241. })
  242. },
  243. obTstrnew(o){
  244. if(Array.isArray(o)){
  245. if(o.length.length===0) return "";
  246. return o[0]?.category_name??""
  247. }
  248. return ''
  249. },
  250. jiaobenFun(){
  251. var that=this;
  252. myRequest({
  253. url: "/api/Goods/selectScript",
  254. method:'post',
  255. data:that.reqData
  256. }).then(res => {
  257. console.log(res.data)
  258. if (res.data.code == 200) {
  259. var arrbig=[
  260. {name:"名称",value:"羽绒服",choosevalue:'',type:'text'},
  261. {name:"颜色",value:"#b1b1b1",choosevalue:'',type:'text'},
  262. {name:"尺码",value:["S","L","M"],choosevalue:'L',type:'select'},
  263. {name:"材质",value:["牛仔","纯棉","羊毛"],choosevalue:'纯棉',type:'select'}
  264. ]
  265. that.arrbig=arrbig;
  266. that.active=2;
  267. console.log(that.arrbig)
  268. }else{
  269. }
  270. })
  271. },
  272. getBase64Image(path){
  273. var that=this;
  274. console.log(" 开始转换")
  275. pathToBase64(path)
  276. .then(base64 => {
  277. that.shibie(base64)
  278. })
  279. .catch(error => {
  280. console.error(error)
  281. })
  282. },
  283. shibie(src){
  284. var that=this;
  285. // 抠图
  286. uni.request({
  287. url: 'https://objseg.market.alicloudapi.com/commonseg/rgba',
  288. method : "post",
  289. header: {
  290. 'Authorization':'APPCODE a4a922a41afa43a0bbca6c831a13bf43',
  291. "Content-Type":"application/json;charset=UTF-8"
  292. },
  293. data:{
  294. photo:src
  295. },
  296. success : function(data) {
  297. that.koutu=data.data.data.result;
  298. that.active=2;
  299. },
  300. error : function(e) {
  301. that.$refs.toast.show({model:'error',label:"网络异常,请重试"})
  302. }
  303. });
  304. },
  305. chuangjianFun(){
  306. var that=this;
  307. if(that.reqData.goods_name==""){
  308. that.$refs.toast.show({model:'warn',label:'请输入商品名称'})
  309. return
  310. }
  311. if(that.category_danarr.length==0){
  312. that.$refs.toast.show({model:'warn',label:'请选择分类'})
  313. return
  314. }else{
  315. that.reqData.category_id=that.category_danarr[0].id
  316. }
  317. if(that.role_danarr.length==0){
  318. that.$refs.toast.show({model:'warn',label:'请选择成员'})
  319. return
  320. }else{
  321. that.reqData.role_id=that.role_danarr[0].id
  322. }
  323. if(that.size_danarr.length!=0){
  324. that.reqData.size=that.size_danarr[0].id
  325. }
  326. that.reqData.image=that.koutu;
  327. that.reqData.thumb=that.koutu;
  328. myRequest({
  329. url: "/api/Goods/addGodds",
  330. method:'post',
  331. data:that.reqData
  332. }).then(res => {
  333. console.log(res.data)
  334. if (res.data.code == 200) {
  335. that.active=3;
  336. }else{
  337. that.$refs.toast.show({model:'error',label:res.data.msg})
  338. }
  339. })
  340. }
  341. },
  342. }
  343. </script>
  344. <style lang="scss">
  345. .zhanshi{
  346. width: 100%;
  347. margin: 0 auto;
  348. margin-top: 10px;
  349. margin-bottom: 40px;
  350. }
  351. /deep/ .tm-menubars .body{
  352. background-color: #1b1b1b !important;
  353. }
  354. /deep/ .kuang{margin:0 !important;padding: 14px !important;margin-bottom: 40px !important;}
  355. // /deep/ .kuang uni-button{background-color: #303440 !important;}
  356. .jindu{width: 90%;margin: 0 auto;display: block;}
  357. .wenzi{width: 94%;margin: 0 auto;}
  358. .nicheng{width: 60%;display: block;margin:0 auto;margin-top: 50px;}
  359. /deep/ .shuru .grey-darken-5{
  360. background-color: #0d0d0d!important;
  361. padding: 0px !important;
  362. }
  363. .shuru{border:1px solid #303030;border-radius: 10px;}
  364. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  365. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  366. .zuo image{width:60px;display: block;}
  367. .you{border:1px solid #303030;border-radius: 10px;padding:10px;}
  368. /deep/ .you .grey-darken-5{
  369. background-color: #0d0d0d!important;
  370. padding: 0px !important;
  371. }
  372. /deep/ .you .text-red{color: white;}
  373. /deep/ .tan .active{background-color: #AAAAAA !important;}
  374. /deep/ .tan .tm-poups .grey-darken-5{background-color: gray !important;}
  375. /deep/ .tan uni-input{text-align: right;}
  376. /deep/ .you .border-grey-darken-4-b-1 {
  377. border-bottom: solid 1px #313131 !important;
  378. }
  379. /deep/ .tm--badges{position: absolute;top: 0px;right:6px}
  380. .logincla{margin-top: 100px;}
  381. /deep/ .logincla .primary{background-color: #303440 !important;}
  382. /deep/ .quindex uni-button{background-color: #0A84FF !important;}
  383. .seka{width: 40px;height: 20px;}
  384. </style>