index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. <view v-for="(item,index) in arrbig">
  32. <tm-pickers 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':buttonColor}" @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. };
  87. },
  88. onLoad() {
  89. },
  90. created() {
  91. this.sys = uni.getSystemInfoSync();
  92. this.getCY();
  93. },
  94. methods: {
  95. /* 显示获取颜色选择弹窗 */
  96. showPickerColorPop(){
  97. this.showPickerColor=true;
  98. },
  99. /* 获取颜色选择回调 */
  100. getPickerColor(color){
  101. /* 隐藏弹窗 */
  102. this.showPickerColor=false;
  103. /* 判断颜色值是否有效 */
  104. if(color){
  105. this.buttonColor=color;
  106. }
  107. },
  108. showPickerColorPop(){
  109. this.showPickerColor=true;
  110. },
  111. xuanze(data){
  112. for(let i=0;i<this.arrbig.length;i++){
  113. if(this.arrbig[i].name==data[0].name){
  114. this.arrbig[i].choosevalue=data[0].data
  115. }
  116. }
  117. },
  118. getCY(){
  119. var that=this;
  120. myRequest({
  121. url: "/api/MemberInfo/getFamilyMember",
  122. method:'post',
  123. data:{family_id:uni.getStorageSync("family_id")}
  124. }).then(res => {
  125. if (res.data.code == 200) {
  126. that.role_arr=res.data.data;
  127. }else{
  128. that.role_arr=[];
  129. }
  130. })
  131. },
  132. obTstr1(o){
  133. if(Array.isArray(o)){
  134. if(o.length.length===0) return "";
  135. return o[0]?.category_name??""
  136. }
  137. return ''
  138. },
  139. obTstr2(o){
  140. if(Array.isArray(o)){
  141. if(o.length.length===0) return "";
  142. return o[0]?.title??""
  143. }
  144. return ''
  145. },
  146. obTstr3(o){
  147. if(Array.isArray(o)){
  148. if(o.length.length===0) return "";
  149. return o[0]?.username??""
  150. }
  151. return ''
  152. },
  153. jixu(){
  154. this.active=1;
  155. },
  156. quindex(){
  157. uni.switchTab({
  158. url: "/pages/wardrobe/index",
  159. })
  160. },
  161. paizhao(){
  162. var that=this;
  163. uni.chooseImage({ //uni官方api,用于选取本地图片
  164. count: 1, //默认9
  165. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  166. sourceType: ['album','camera'], //从相册选择
  167. success: function (res) {
  168. that.imgpath = res.tempFilePaths[0] //先获得本地文件的路径列表,存储到数组
  169. console.log(that.imgpath) //注意该api会将路径转换为blob格式
  170. // that.getBase64Image(that.imgpath);
  171. // 调脚本接口
  172. that.jiaobenFun()
  173. }
  174. })
  175. },
  176. obTstrnew(o){
  177. if(Array.isArray(o)){
  178. if(o.length.length===0) return "";
  179. return o[0]?.category_name??""
  180. }
  181. return ''
  182. },
  183. jiaobenFun(){
  184. var that=this;
  185. myRequest({
  186. url: "/api/Goods/selectScript",
  187. method:'post',
  188. data:''
  189. }).then(res => {
  190. if (res.data.code == 200) {
  191. // var arrbig=[
  192. // {name:"名称",value:"羽绒服",choosevalue:'',type:'text'},
  193. // {name:"颜色",value:"#b1b1b1",choosevalue:'',type:'text'},
  194. // {name:"尺码",value:["S","L","M"],choosevalue:'L',type:'select'},
  195. // {name:"材质",value:["牛仔","纯棉","羊毛"],choosevalue:'纯棉',type:'select'}
  196. // ]
  197. that.arrbig=res.data.data.parm;
  198. myRequest({
  199. url: "/api/Category/list",
  200. method:'post',
  201. data:''
  202. }).then(res => {
  203. if (res.data.code == 200) {
  204. var valuearr=[],rolevaluearr=[];
  205. for(let i=0;i<res.data.data.length;i++){
  206. valuearr.push(res.data.data[i].category_name)
  207. }
  208. for(let i=0;i<that.role_arr.length;i++){
  209. rolevaluearr.push(that.role_arr[i].username)
  210. }
  211. var arrsmall=[
  212. {name:"分类",value:valuearr,choosevalue:'',type:'select',classid:''},
  213. {name:"所属成员",value:rolevaluearr,choosevalue:'',type:'select',classid:''},
  214. ];
  215. that.arrbig=arrsmall.concat(that.arrbig)
  216. that.fenlei=res.data.data;
  217. that.active=2;
  218. }else{
  219. }
  220. })
  221. }else{
  222. }
  223. })
  224. },
  225. getBase64Image(path){
  226. var that=this;
  227. pathToBase64(path)
  228. .then(base64 => {
  229. that.shibie(base64)
  230. })
  231. .catch(error => {
  232. console.error(error)
  233. })
  234. },
  235. shibie(src){
  236. var that=this;
  237. // 抠图
  238. uni.request({
  239. url: 'https://objseg.market.alicloudapi.com/commonseg/rgba',
  240. method : "post",
  241. header: {
  242. 'Authorization':'APPCODE a4a922a41afa43a0bbca6c831a13bf43',
  243. "Content-Type":"application/json;charset=UTF-8"
  244. },
  245. data:{
  246. photo:src
  247. },
  248. success : function(data) {
  249. that.koutu=data.data.data.result;
  250. that.active=2;
  251. },
  252. error : function(e) {
  253. that.$refs.toast.show({model:'error',label:"网络异常,请重试"})
  254. }
  255. });
  256. },
  257. chuangjianFun(){
  258. var that=this;
  259. for(let i=0;i<that.arrbig.length;i++){
  260. if(that.arrbig[i].choosevalue==""){
  261. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  262. return
  263. }
  264. }
  265. // 分类id
  266. for(let i=0;i<that.fenlei.length;i++){
  267. if(that.fenlei[i].category_name==that.arrbig[0].choosevalue){
  268. that.arrbig[0].classid=that.fenlei[i].id
  269. }
  270. }
  271. // 成员id
  272. for(let i=0;i<that.role_arr.length;i++){
  273. if(that.role_arr[i].category_name==that.arrbig[0].choosevalue){
  274. that.arrbig[0].classid=that.role_arr[i].id
  275. }
  276. }
  277. console.log(that.arrbig)
  278. // that.reqData.image=that.koutu;
  279. myRequest({
  280. url: "/api/Goods/addGodds",
  281. method:'post',
  282. data:that.arrbig
  283. }).then(res => {
  284. if (res.data.code == 200) {
  285. that.active=3;
  286. }else{
  287. that.$refs.toast.show({model:'error',label:res.data.msg})
  288. }
  289. })
  290. }
  291. },
  292. }
  293. </script>
  294. <style lang="scss">
  295. .zhanshi{
  296. width: 100%;
  297. margin: 0 auto;
  298. margin-top: 10px;
  299. margin-bottom: 40px;
  300. }
  301. /deep/ .tm-menubars .body{
  302. background-color: #1b1b1b !important;
  303. }
  304. /deep/ .kuang{margin:0 !important;padding: 14px !important;margin-bottom: 40px !important;}
  305. // /deep/ .kuang uni-button{background-color: #303440 !important;}
  306. .jindu{width: 90%;margin: 0 auto;display: block;}
  307. .wenzi{width: 94%;margin: 0 auto;}
  308. .nicheng{width: 60%;display: block;margin:0 auto;margin-top: 50px;}
  309. /deep/ .shuru .grey-darken-5{
  310. background-color: #0d0d0d!important;
  311. padding: 0px !important;
  312. }
  313. .shuru{border:1px solid #303030;border-radius: 10px;}
  314. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  315. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  316. .zuo image{width:60px;display: block;}
  317. .you{border:1px solid #303030;border-radius: 10px;padding:10px;}
  318. /deep/ .you .grey-darken-5{
  319. background-color: #0d0d0d!important;
  320. padding: 0px !important;
  321. }
  322. /deep/ .you .text-red{color: white;}
  323. /deep/ .tan .active{background-color: #AAAAAA !important;}
  324. /deep/ .tan .tm-poups .grey-darken-5{background-color: gray !important;}
  325. /deep/ .tan uni-input{text-align: right;}
  326. /deep/ .you .border-grey-darken-4-b-1 {
  327. border-bottom: solid 1px #313131 !important;
  328. }
  329. /deep/ .tm--badges{position: absolute;top: 0px;right:6px}
  330. .logincla{margin-top: 100px;}
  331. /deep/ .logincla .primary{background-color: #303440 !important;}
  332. /deep/ .quindex uni-button{background-color: #0A84FF !important;}
  333. .seka{width: 40px;height: 20px;}
  334. </style>