index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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. <tm-pickers v-for="(item,index) in arrbig" @confirm="xuanze" :indexfu="index" :list="item.value">
  35. <tm-input title="分类" placeholder="请选择分类" v-model="item.choosename" disabled right-icon="icon-angle-right"></tm-input>
  36. </tm-pickers>
  37. <!-- <tm-listitem
  38. v-for="item in arrbig"
  39. :left-icon-size="80"
  40. value="打开"
  41. title="支付"
  42. label="微信和支付宝微信和支付宝微信和支付宝微信和支付宝"
  43. left-icon="https://cdn.roundicons.com/wp-content/uploads/2017/09/Lego-freebie-icon.png"
  44. show-left-icon
  45. ></tm-listitem> -->
  46. <!-- <tm-input :required="true" title="商品名称" v-model="reqData.goods_name" align="right"></tm-input> -->
  47. <!-- <tm-pickers class="tan" :default-value.sync="category_danarr" rang-key="category_name" :list="category_arr">
  48. <tm-input :required="true" title="分类" placeholder="请选择分类" :value="obTstr1(category_danarr,'category_name')" right-icon="icon-angle-right"></tm-input>
  49. </tm-pickers> -->
  50. <!-- <tm-pickers class="tan" :default-value.sync="role_danarr" rang-key="username" :list="role_arr">
  51. <tm-input title="所属成员" :required="true" placeholder="请选择所属成员" disabled :value="obTstr3(role_danarr)" right-icon="icon-angle-right"></tm-input>
  52. </tm-pickers> -->
  53. <!-- <tm-input title="年份" v-model="reqData.year" align="right"></tm-input>
  54. <tm-input title="颜色" v-model="reqData.color" align="right"></tm-input>
  55. <tm-pickers class="tan" :default-value.sync="size_danarr" rang-key="title" :list="size_arr">
  56. <tm-input title="尺码" placeholder="请选择尺码" disabled :value="obTstr2(size_danarr)" right-icon="icon-angle-right"></tm-input>
  57. </tm-pickers>
  58. <tm-input title="适用人群" v-model="reqData.type" align="right"></tm-input>
  59. <tm-input title="品牌" v-model="reqData.brand" align="right"></tm-input>
  60. <tm-input title="材料" v-model="reqData.science" align="right"></tm-input> -->
  61. </view>
  62. <tm-button :round="24" class="sao mb-40 mt-40" @click="chuangjianFun()" block>提交</tm-button>
  63. </view>
  64. <view v-if="active==3">
  65. <tm-translate ref="a_1" :auto="true" animation-name="zoomIn">
  66. <image block class="nicheng" mode="widthFix" src="/static/img/52.png"></image>
  67. </tm-translate>
  68. <view class="text-align-center mt-20">
  69. <text class="text-size-m text-white">衣物添加成功!</text>
  70. </view>
  71. <view class="text-align-center mb-40">
  72. <text class="text-size-m">您可以在我的衣柜中添加或删除衣物</text>
  73. </view>
  74. <view class="px-24">
  75. <tm-button @click="jixu()" :round="24" block class="mt-50 logincla">继续添加衣物</tm-button>
  76. <tm-button @click="quindex()" theme="primary" :round="24" block class="mt-30 quindex">进入衣柜</tm-button>
  77. </view>
  78. </view>
  79. </tm-sheet>
  80. </div>
  81. <!-- 弹出层消息 -->
  82. <tm-message ref="toast"></tm-message>
  83. </view>
  84. </template>
  85. <script>
  86. import{myRequest} from '@/api/request.js'
  87. import { pathToBase64, base64ToPath } from '@/js_sdk/mmmm-image-tools/index.js'
  88. export default {
  89. data() {
  90. return {
  91. arrbig:[],
  92. koutu:'/static/img/53.png',
  93. active:2,
  94. category_arr:[],
  95. category_danarr:[],
  96. size_arr:[
  97. {title:"S",id:1},
  98. {title:"M",id:2},
  99. {title:"L",id:3},
  100. {title:"XL",id:4},
  101. {title:"XXL",id:5},
  102. {title:"其他",id:6},
  103. ],
  104. size_danarr:[],
  105. role_arr:[],
  106. role_danarr:[],
  107. reqData:{
  108. goods_name:'',
  109. category_id:'',
  110. year:'',
  111. color:'',
  112. image:'',
  113. type:'',
  114. thumb:'',
  115. size:'',
  116. brand:'',
  117. science:'',
  118. role_id:''
  119. },
  120. };
  121. },
  122. onLoad() {
  123. },
  124. created() {
  125. this.sys = uni.getSystemInfoSync();
  126. this.getFl();
  127. this.getCY();
  128. this.jiaobenFun()
  129. },
  130. methods: {
  131. xuanze(data){
  132. var index=data[0].index;
  133. // this.arrbig[index].choosename=data[0].data;
  134. console.log(data[0].data)
  135. console.log(this.arrbig)
  136. },
  137. getFl(){
  138. var that=this;
  139. myRequest({
  140. url: "/api/Category/list",
  141. method:'post',
  142. data:{}
  143. }).then(res => {
  144. console.log(res.data)
  145. if (res.data.code == 200) {
  146. this.category_arr=res.data.data;
  147. }else{
  148. that.category_arr=[];
  149. }
  150. })
  151. },
  152. getCY(){
  153. var that=this;
  154. myRequest({
  155. url: "/api/MemberInfo/getFamilyMember",
  156. method:'post',
  157. data:{family_id:uni.getStorageSync("family_id")}
  158. }).then(res => {
  159. if (res.data.code == 200) {
  160. that.role_arr=res.data.data;
  161. }else{
  162. that.role_arr=[];
  163. }
  164. })
  165. },
  166. obTstr1(o){
  167. if(Array.isArray(o)){
  168. if(o.length.length===0) return "";
  169. return o[0]?.category_name??""
  170. }
  171. return ''
  172. },
  173. obTstr2(o){
  174. if(Array.isArray(o)){
  175. if(o.length.length===0) return "";
  176. return o[0]?.title??""
  177. }
  178. return ''
  179. },
  180. obTstr3(o){
  181. if(Array.isArray(o)){
  182. if(o.length.length===0) return "";
  183. return o[0]?.username??""
  184. }
  185. return ''
  186. },
  187. jixu(){
  188. this.active=1;
  189. },
  190. quindex(){
  191. uni.navigateTo({
  192. url: "/pages/index/index?index=1",
  193. })
  194. },
  195. paizhao(){
  196. var that=this;
  197. uni.chooseImage({ //uni官方api,用于选取本地图片
  198. count: 1, //默认9
  199. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  200. sourceType: ['album','camera'], //从相册选择
  201. success: function (res) {
  202. that.imgpath = res.tempFilePaths[0] //先获得本地文件的路径列表,存储到数组
  203. console.log(that.imgpath) //注意该api会将路径转换为blob格式
  204. // that.getBase64Image(that.imgpath);
  205. // 调脚本接口
  206. that.jiaobenFun()
  207. }
  208. })
  209. },
  210. obTstrnew(o){
  211. if(Array.isArray(o)){
  212. if(o.length.length===0) return "";
  213. return o[0]?.category_name??""
  214. }
  215. return ''
  216. },
  217. jiaobenFun(){
  218. var that=this;
  219. myRequest({
  220. url: "/api/Goods/selectScript",
  221. method:'post',
  222. data:that.reqData
  223. }).then(res => {
  224. console.log(res.data)
  225. if (res.data.code == 200) {
  226. var arrbig=[
  227. {name:"颜色",value:["白色","绿色","蓝色"],choosevalue:'',choosename:''}
  228. ]
  229. that.arrbig=arrbig;
  230. that.active=2;
  231. console.log(that.arrbig)
  232. }else{
  233. }
  234. })
  235. },
  236. getBase64Image(path){
  237. var that=this;
  238. console.log(" 开始转换")
  239. pathToBase64(path)
  240. .then(base64 => {
  241. that.shibie(base64)
  242. })
  243. .catch(error => {
  244. console.error(error)
  245. })
  246. },
  247. shibie(src){
  248. var that=this;
  249. // 抠图
  250. uni.request({
  251. url: 'https://objseg.market.alicloudapi.com/commonseg/rgba',
  252. method : "post",
  253. header: {
  254. 'Authorization':'APPCODE a4a922a41afa43a0bbca6c831a13bf43',
  255. "Content-Type":"application/json;charset=UTF-8"
  256. },
  257. data:{
  258. photo:src
  259. },
  260. success : function(data) {
  261. that.koutu=data.data.data.result;
  262. that.active=2;
  263. },
  264. error : function(e) {
  265. that.$refs.toast.show({model:'error',label:"网络异常,请重试"})
  266. }
  267. });
  268. },
  269. chuangjianFun(){
  270. var that=this;
  271. if(that.reqData.goods_name==""){
  272. that.$refs.toast.show({model:'warn',label:'请输入商品名称'})
  273. return
  274. }
  275. if(that.category_danarr.length==0){
  276. that.$refs.toast.show({model:'warn',label:'请选择分类'})
  277. return
  278. }else{
  279. that.reqData.category_id=that.category_danarr[0].id
  280. }
  281. if(that.role_danarr.length==0){
  282. that.$refs.toast.show({model:'warn',label:'请选择成员'})
  283. return
  284. }else{
  285. that.reqData.role_id=that.role_danarr[0].id
  286. }
  287. if(that.size_danarr.length!=0){
  288. that.reqData.size=that.size_danarr[0].id
  289. }
  290. that.reqData.image=that.koutu;
  291. that.reqData.thumb=that.koutu;
  292. myRequest({
  293. url: "/api/Goods/addGodds",
  294. method:'post',
  295. data:that.reqData
  296. }).then(res => {
  297. console.log(res.data)
  298. if (res.data.code == 200) {
  299. that.active=3;
  300. }else{
  301. that.$refs.toast.show({model:'error',label:res.data.msg})
  302. }
  303. })
  304. }
  305. },
  306. }
  307. </script>
  308. <style lang="scss">
  309. .zhanshi{
  310. width: 100%;
  311. margin: 0 auto;
  312. margin-top: 10px;
  313. margin-bottom: 40px;
  314. }
  315. /deep/ .tm-menubars .body{
  316. background-color: #1b1b1b !important;
  317. }
  318. /deep/ .kuang{margin:0 !important;padding: 14px !important;margin-bottom: 40px !important;}
  319. // /deep/ .kuang uni-button{background-color: #303440 !important;}
  320. .jindu{width: 90%;margin: 0 auto;display: block;}
  321. .wenzi{width: 94%;margin: 0 auto;}
  322. .nicheng{width: 60%;display: block;margin:0 auto;margin-top: 50px;}
  323. /deep/ .shuru .grey-darken-5{
  324. background-color: #0d0d0d!important;
  325. padding: 0px !important;
  326. }
  327. .shuru{border:1px solid #303030;border-radius: 10px;}
  328. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  329. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  330. .zuo image{width:60px;display: block;}
  331. .you{border:1px solid #303030;border-radius: 10px;padding:10px;}
  332. /deep/ .you .grey-darken-5{
  333. background-color: #0d0d0d!important;
  334. padding: 0px !important;
  335. }
  336. /deep/ .you .text-red{color: white;}
  337. /deep/ .tan .active{background-color: #AAAAAA !important;}
  338. /deep/ .tan .tm-poups .grey-darken-5{background-color: gray !important;}
  339. /deep/ .tan uni-input{text-align: right;}
  340. /deep/ .you .border-grey-darken-4-b-1 {
  341. border-bottom: solid 1px #313131 !important;
  342. }
  343. /deep/ .tm--badges{position: absolute;top: 0px;right:6px}
  344. .logincla{margin-top: 100px;}
  345. /deep/ .logincla .primary{background-color: #303440 !important;}
  346. /deep/ .quindex uni-button{background-color: #0A84FF !important;}
  347. </style>