index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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 || active==2)" class="jindu" src="/static/img/49.png" mode="widthFix"></image>
  8. <image v-if="active==3" class="jindu" src="/static/img/50.png" mode="widthFix"></image>
  9. <image v-if="active==4" 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 class="wenzi flex-between flex-center">
  22. <view>
  23. <text class="text-size-s">2022-11-28</text>
  24. </view>
  25. <view>
  26. <text class="text-size-s">等待审批</text>
  27. </view>
  28. <view>
  29. <text class="text-size-s">等待审批</text>
  30. </view>
  31. </view> -->
  32. <view v-if="active==1">
  33. <view class="mt-20 ml-15">
  34. <text class="text-white text-size-m">*扫描柜体上的二维码和衣柜绑定</text>
  35. </view>
  36. <image block class="zhanshi" mode="widthFix" src="/static/img/48.png"></image>
  37. <tm-button :round="24" class="sao mb-40" @click="saoma()" block>扫二维码</tm-button>
  38. </view>
  39. <view v-if="active==2">
  40. <tm-translate ref="a_1" :auto="true" animation-name="zoomIn">
  41. <image block class="nicheng" mode="widthFix" src="/static/img/52.png"></image>
  42. </tm-translate>
  43. <view class="text-align-center mt-20 mb-40">
  44. <text class="text-size-m">衣柜和手机关联成功</text>
  45. </view>
  46. <view class="black shuru pa-30">
  47. <tm-form>
  48. <view class="text-size-m">请输入家庭名称</view>
  49. <tm-input name="title" v-model="reqData.familyname" clear placeholder="相亲相爱一家人"></tm-input>
  50. </tm-form>
  51. </view>
  52. <tm-button :round="24" class="sao mb-40 mt-40" @click="chuangjianFun()" block>创建家庭</tm-button>
  53. </view>
  54. <view v-if="active==3">
  55. <view>
  56. <view class="fl zuo" style="width:70px;">
  57. <view class="flex-center flex-col mt-30" style="position: relative;" v-for="(item,index) in reqData.role">
  58. <image @click="qiehuanren(index)" block v-if="index==0" mode="widthFix" src="/static/img/53.png"></image>
  59. <image @click="qiehuanren(index)" block v-else mode="widthFix" src="/static/img/61.png"></image>
  60. <tm-badges icon="icon-times" @click="shanchu(item.timestamp)" v-if="(show==index && index !=0)"></tm-badges>
  61. </view>
  62. <view class="flex-center flex-col mt-30" style="position: relative;" v-if="reqData.role.length<4">
  63. <image block mode="widthFix" src="/static/img/54.png" @click="add()"></image>
  64. </view>
  65. </view>
  66. <view class="fr you black mt-30" style="width: calc(100% - 100px);" v-for="(item1,index1) in reqData.role" v-if="show==index1">
  67. <tm-input :required="true" title="用户名" v-model="item1.username" placeholder="你想叫自己什么" align="right"></tm-input>
  68. <tm-input :required="true" title="身高(cm)" v-model="item1.height" align="right"></tm-input>
  69. <tm-input :required="true" title="体重(kg)" v-model="item1.weight" align="right"></tm-input>
  70. <tm-pickers class="tan" :default-value.sync="item1.body_arr" rang-key="title" :list="chelianglis">
  71. <tm-input name="shencai" title="身材" placeholder="请选择车型" disabled :value="obTstr2(item1.body_arr)" right-icon="icon-angle-right"></tm-input>
  72. </tm-pickers>
  73. </view>
  74. </view>
  75. <view style="clear: both;"></view>
  76. <tm-button :round="24" class="sao mb-40" style="margin-top: 50px;" @click="tijiao()" block>下一步</tm-button>
  77. </view>
  78. <view v-if="active==4">
  79. <tm-translate ref="a_1" :auto="true" animation-name="zoomIn">
  80. <image block class="nicheng" mode="widthFix" src="/static/img/52.png"></image>
  81. </tm-translate>
  82. <view class="text-align-center mt-20">
  83. <text class="text-size-m text-white">家庭创建成功!</text>
  84. </view>
  85. <view class="text-align-center mb-40">
  86. <text class="text-size-m">衣柜和手机关联成功</text>
  87. </view>
  88. <view class="px-24">
  89. <tm-button theme="primary" @click="quyifu()" :round="24" block class="mt-50 logincla">添加衣服</tm-button>
  90. <tm-button @click="quindex()" theme="primary" :round="24" block class="mt-30 quindex">进入首页</tm-button>
  91. </view>
  92. </view>
  93. </tm-sheet>
  94. </div>
  95. <!-- 弹出层消息 -->
  96. <tm-message ref="toast"></tm-message>
  97. </view>
  98. </template>
  99. <script>
  100. import{myRequest} from '@/api/request.js'
  101. export default {
  102. data() {
  103. return {
  104. shencaiList:[
  105. {title:"梨形",id:21},
  106. {title:"标准",id:31},
  107. {title:"胖子",id:41},
  108. {title:"瘦子",id:51},
  109. {title:"模特",id:61},
  110. ],
  111. active:1,
  112. chelianglis:[
  113. {title:"标准",id:1},
  114. {title:"偏瘦",id:2},
  115. {title:"偏胖",id:3},
  116. {title:"梨形",id:4}
  117. ],
  118. show:0,
  119. reqData:{
  120. wardrode_no:'6943819164690',
  121. familyname:'',
  122. role:[{
  123. username:'',
  124. weight:'',
  125. height:'',
  126. body_type:'',
  127. body_arr:[]
  128. }]
  129. },
  130. };
  131. },
  132. onLoad() {
  133. },
  134. created() {
  135. this.sys = uni.getSystemInfoSync();
  136. },
  137. methods: {
  138. qiehuanren(index){
  139. this.show=index;
  140. },
  141. quyifu(){
  142. uni.navigateTo({
  143. url: "/pages/luru/index",
  144. })
  145. },
  146. quindex(){
  147. uni.navigateTo({
  148. url: "/pages/index/index",
  149. })
  150. },
  151. tijiao(){
  152. var that=this;
  153. var arr=this.reqData.role;
  154. for(let i=0;i<arr.length;i++){
  155. if(arr[i].username==""){
  156. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  157. return;
  158. }if(arr[i].weight==""){
  159. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  160. return;
  161. }if(arr[i].height==""){
  162. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  163. return;
  164. }
  165. if(arr[i].body_arr.length !=0){
  166. arr[i].body_type=arr[i].body_arr[0].id;
  167. }
  168. }
  169. console.log(this.reqData)
  170. myRequest({
  171. url: "/api/Family/addFamilyMember",
  172. method:'post',
  173. data:that.reqData
  174. }).then(res => {
  175. console.log(res.data)
  176. if (res.data.code == 200) {
  177. uni.setStorageSync("family_id",res.data.data.family_id)
  178. that.$refs.toast.show({model:'success',label:res.data.msg})
  179. that.active=4;
  180. }else{
  181. that.$refs.toast.show({model:'error',label:res.data.msg})
  182. }
  183. })
  184. },
  185. add(){
  186. var timestamp = Date.parse(new Date());
  187. var obj={
  188. username:'',
  189. weight:'',
  190. height:'',
  191. body_type:'',
  192. body_arr:[],
  193. timestamp:timestamp
  194. }
  195. this.reqData.role.push(obj);
  196. this.show=this.reqData.role.length-1;
  197. },
  198. shanchu(timestamp){
  199. var index = this.reqData.role.findIndex((item) => {
  200. return item.timestamp == timestamp;
  201. });
  202. this.reqData.role.splice(index, 1);
  203. this.show=this.reqData.role.length-1;
  204. },
  205. obTstr2(o){
  206. if(Array.isArray(o)){
  207. if(o.length.length===0) return "";
  208. return o[0]?.title??""
  209. }
  210. return ''
  211. },
  212. saoma(){
  213. var that=this;
  214. uni.scanCode({
  215. scanType: ['barCode'],
  216. success: function (res) {
  217. console.log('条码类型:' + res.scanType);
  218. console.log('条码内容:' + res.result);
  219. that.reqData.wardrode_no=res.result;
  220. that.active=2;
  221. },
  222. error : function(e) {
  223. alert("网络异常,请重试");
  224. }
  225. })
  226. },
  227. chuangjianFun(){
  228. var that=this;
  229. if(that.reqData.familyname==""){
  230. that.$refs.toast.show({model:'warn',label:'请输入家庭名称'})
  231. return
  232. }
  233. that.active=3;
  234. }
  235. },
  236. }
  237. </script>
  238. <style lang="scss">
  239. .zhanshi{
  240. width: 100%;
  241. margin: 0 auto;
  242. margin-top: 10px;
  243. margin-bottom: 40px;
  244. }
  245. /deep/ .tm-menubars .body{
  246. background-color: #1b1b1b !important;
  247. }
  248. /deep/ .kuang{margin:0 !important;padding: 14px !important;margin-bottom: 40px !important;}
  249. /deep/ .kuang uni-button{background-color: #303440 !important;}
  250. .jindu{width: 90%;margin: 0 auto;display: block;}
  251. .wenzi{width: 94%;margin: 0 auto;}
  252. .nicheng{width: 130px;height:132px;display: block;margin:0 auto;margin-top: 50px;}
  253. /deep/ .shuru .grey-darken-5{
  254. background-color: #0d0d0d!important;
  255. padding: 0px !important;
  256. }
  257. .shuru{border:1px solid #303030;border-radius: 10px;}
  258. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  259. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  260. .zuo image{width:60px;display: block;}
  261. .you{border:1px solid #303030;border-radius: 10px;padding:10px;height: 300px;}
  262. /deep/ .you .grey-darken-5{
  263. background-color: #0d0d0d!important;
  264. padding: 0px !important;
  265. }
  266. /deep/ .you .text-red{color: white;}
  267. /deep/ .tan .active{background-color: #AAAAAA !important;}
  268. /deep/ .tan .tm-poups .grey-darken-5{background-color: gray !important;}
  269. /deep/ .tan uni-input{text-align: right;}
  270. /deep/ .you .border-grey-darken-4-b-1 {
  271. border-bottom: solid 1px #313131 !important;
  272. }
  273. /deep/ .tm--badges{position: absolute;top: 0px;right:6px}
  274. .logincla{margin-top: 100px;}
  275. /deep/ .quindex uni-button{background-color: #0A84FF !important;}
  276. </style>