index.vue 11 KB

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