index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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" style="position: relative;width: 70px;height: 70px;" 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. <image src="/static/icon/error.png" class="error" @click="shanchu(item.timestamp)" v-if="(show==index && index !=0)"></image>
  61. </view>
  62. <view class="flex-center flex-col" style="position: relative;margin-top: 40px;" 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. <tm-dialog @confirm="querentm" :inputVala="inputVala" confirmText="确定" :showCancel="false" model="confirm" v-model="show3" content="请确认条码内容是否正确" theme="split"></tm-dialog>
  95. </div>
  96. <!-- 弹出层消息 -->
  97. <tm-message ref="toast"></tm-message>
  98. </view>
  99. </template>
  100. <script>
  101. import{myRequest} from '@/api/request.js'
  102. export default {
  103. data() {
  104. return {
  105. show3:false,
  106. inputVala:'',
  107. shencaiList:[
  108. {title:"梨形",id:21},
  109. {title:"标准",id:31},
  110. {title:"胖子",id:41},
  111. {title:"瘦子",id:51},
  112. {title:"模特",id:61},
  113. ],
  114. active:1,
  115. chelianglis:[
  116. {title:"标准",id:1},
  117. {title:"偏瘦",id:2},
  118. {title:"偏胖",id:3},
  119. {title:"梨形",id:4}
  120. ],
  121. show:0,
  122. reqData:{
  123. wardrode_no:'',
  124. familyname:'',
  125. role:[{
  126. username:'',
  127. weight:'',
  128. height:'',
  129. body_type:'',
  130. body_arr:[]
  131. }]
  132. },
  133. };
  134. },
  135. onLoad() {
  136. },
  137. created() {
  138. this.sys = uni.getSystemInfoSync();
  139. },
  140. methods: {
  141. qiehuanren(index){
  142. this.show=index;
  143. },
  144. quyifu(){
  145. uni.navigateTo({
  146. url: "/pages/luru/index",
  147. })
  148. },
  149. quindex(){
  150. uni.switchTab({
  151. url: "/pages/index/index",
  152. })
  153. },
  154. tijiao(){
  155. var that=this;
  156. var arr=this.reqData.role;
  157. for(let i=0;i<arr.length;i++){
  158. if(arr[i].username==""){
  159. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  160. return;
  161. }if(arr[i].weight==""){
  162. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  163. return;
  164. }if(arr[i].height==""){
  165. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  166. return;
  167. }
  168. if(arr[i].body_arr.length !=0){
  169. arr[i].body_type=arr[i].body_arr[0].data.id;
  170. }
  171. }
  172. myRequest({
  173. url: "/api/Family/addFamilyMember",
  174. method:'post',
  175. data:that.reqData
  176. }).then(res => {
  177. if (res.data.code == 200) {
  178. uni.setStorageSync("family_id",res.data.data.family_id)
  179. that.$refs.toast.show({model:'success',label:res.data.msg})
  180. that.active=4;
  181. }else{
  182. that.$refs.toast.show({model:'error',label:res.data.msg})
  183. }
  184. })
  185. },
  186. add(){
  187. var timestamp = Date.parse(new Date());
  188. var obj={
  189. username:'',
  190. weight:'',
  191. height:'',
  192. body_type:'',
  193. body_arr:[],
  194. timestamp:timestamp
  195. }
  196. this.reqData.role.push(obj);
  197. this.show=this.reqData.role.length-1;
  198. },
  199. shanchu(timestamp){
  200. var index = this.reqData.role.findIndex((item) => {
  201. return item.timestamp == timestamp;
  202. });
  203. this.reqData.role.splice(index, 1);
  204. this.show=this.reqData.role.length-1;
  205. },
  206. obTstr2(o){
  207. if(Array.isArray(o)){
  208. if(o.length.length===0) return "";
  209. var name=o[0]?o[0].data.title:'';
  210. return name
  211. }
  212. return ''
  213. },
  214. querentm(e){
  215. this.reqData.wardrode_no=e;
  216. this.active=2;
  217. },
  218. saoma(){
  219. var that=this;
  220. uni.scanCode({
  221. scanType: ['barCode'],
  222. success: function (res) {
  223. console.log('条码类型:' + res.scanType);
  224. console.log('条码内容:' + res.result);
  225. that.inputVala=res.result;
  226. that.show3=true;
  227. },
  228. error : function(e) {
  229. alert("网络异常,请重试");
  230. }
  231. })
  232. },
  233. chuangjianFun(){
  234. var that=this;
  235. if(that.reqData.familyname==""){
  236. that.$refs.toast.show({model:'warn',label:'请输入家庭名称'})
  237. return
  238. }
  239. that.active=3;
  240. }
  241. },
  242. }
  243. </script>
  244. <style lang="scss">
  245. .zhanshi{
  246. width: 100%;
  247. margin: 0 auto;
  248. margin-top: 10px;
  249. margin-bottom: 40px;
  250. }
  251. /deep/ .tm-menubars .body{
  252. background-color: #1b1b1b !important;
  253. }
  254. /deep/ .kuang{margin:0 !important;padding: 14px !important;margin-bottom: 40px !important;}
  255. /deep/ .kuang uni-button{background-color: #303440 !important;}
  256. .jindu{width: 90%;margin: 0 auto;display: block;}
  257. .wenzi{width: 94%;margin: 0 auto;}
  258. .nicheng{width: 130px;height:132px;display: block;margin:0 auto;margin-top: 50px;}
  259. /deep/ .shuru .grey-darken-5{
  260. background-color: #0d0d0d!important;
  261. padding: 0px !important;
  262. }
  263. .shuru{border:1px solid #303030;border-radius: 10px;}
  264. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  265. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  266. .zuo image{width:60px;display: block;position: absolute}
  267. .you{border:1px solid #303030;border-radius: 10px;padding:10px;height: 300px;}
  268. /deep/ .you .grey-darken-5{
  269. background-color: #0d0d0d!important;
  270. padding: 0px !important;
  271. }
  272. /deep/ .you .text-red{color: white;}
  273. /deep/ .tan .active{background-color: #AAAAAA !important;}
  274. /deep/ .tan .tm-poups .grey-darken-5{background-color: gray !important;}
  275. /deep/ .tan uni-input{text-align: right;}
  276. /deep/ .you .border-grey-darken-4-b-1 {
  277. border-bottom: solid 1px #313131 !important;
  278. }
  279. /deep/ .tm--badges{position: absolute;top: 0px !important;right:6px;width: 18px;height: 18px;}
  280. .logincla{margin-top: 100px;}
  281. /deep/ .quindex uni-button{background-color: #0A84FF !important;}
  282. .error{height:18px !important;width: 18px !important;right: 3px !important;top:6px !important}
  283. </style>