index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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:'6943819164690',
  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.setStorageSync("shuaxin", 1); //赋值
  151. uni.switchTab({
  152. url: "/pages/wardrobe/index",
  153. success: function (e) {
  154. // var page = getCurrentPages()[0]
  155. // console.log(page)
  156. // if (page == undefined || page == null) return;
  157. // page.created();
  158. }
  159. })
  160. },
  161. tijiao(){
  162. var that=this;
  163. var arr=this.reqData.role;
  164. for(let i=0;i<arr.length;i++){
  165. if(arr[i].username==""){
  166. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  167. return;
  168. }if(arr[i].weight==""){
  169. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  170. return;
  171. }if(arr[i].height==""){
  172. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  173. return;
  174. }
  175. if(arr[i].body_arr.length !=0){
  176. arr[i].body_type=arr[i].body_arr[0].data.id;
  177. }
  178. }
  179. myRequest({
  180. url: "/api/Family/addFamilyMember",
  181. method:'post',
  182. data:that.reqData
  183. }).then(res => {
  184. if (res.data.code == 200) {
  185. uni.setStorageSync("family_id",res.data.data.family_id)
  186. that.$refs.toast.show({model:'success',label:res.data.msg})
  187. that.active=4;
  188. }else{
  189. that.$refs.toast.show({model:'error',label:res.data.msg})
  190. }
  191. })
  192. },
  193. add(){
  194. var timestamp = Date.parse(new Date());
  195. var obj={
  196. username:'',
  197. weight:'',
  198. height:'',
  199. body_type:'',
  200. body_arr:[],
  201. timestamp:timestamp
  202. }
  203. this.reqData.role.push(obj);
  204. this.show=this.reqData.role.length-1;
  205. },
  206. shanchu(timestamp){
  207. var index = this.reqData.role.findIndex((item) => {
  208. return item.timestamp == timestamp;
  209. });
  210. this.reqData.role.splice(index, 1);
  211. this.show=this.reqData.role.length-1;
  212. },
  213. obTstr2(o){
  214. if(Array.isArray(o)){
  215. if(o.length.length===0) return "";
  216. var name=o[0]?o[0].data.title:'';
  217. return name
  218. }
  219. return ''
  220. },
  221. querentm(e){
  222. this.reqData.wardrode_no=e;
  223. this.active=2;
  224. },
  225. saoma(){
  226. var that=this;
  227. uni.scanCode({
  228. scanType: ['barCode'],
  229. success: function (res) {
  230. console.log('条码类型:' + res.scanType);
  231. console.log('条码内容:' + res.result);
  232. that.inputVala=res.result;
  233. that.show3=true;
  234. },
  235. error : function(e) {
  236. alert("网络异常,请重试");
  237. }
  238. })
  239. },
  240. chuangjianFun(){
  241. var that=this;
  242. if(that.reqData.familyname==""){
  243. that.$refs.toast.show({model:'warn',label:'请输入家庭名称'})
  244. return
  245. }
  246. that.active=3;
  247. }
  248. },
  249. }
  250. </script>
  251. <style lang="scss">
  252. .zhanshi{
  253. width: 100%;
  254. margin: 0 auto;
  255. margin-top: 10px;
  256. margin-bottom: 40px;
  257. }
  258. /deep/ .tm-menubars .body{
  259. background-color: #1b1b1b !important;
  260. }
  261. /deep/ .kuang{margin:0 !important;padding: 14px !important;margin-bottom: 40px !important;}
  262. /deep/ .kuang uni-button{background-color: #303440 !important;}
  263. .jindu{width: 90%;margin: 0 auto;display: block;}
  264. .wenzi{width: 94%;margin: 0 auto;}
  265. .nicheng{width: 130px;height:132px;display: block;margin:0 auto;margin-top: 50px;}
  266. /deep/ .shuru .grey-darken-5{
  267. background-color: #0d0d0d!important;
  268. padding: 0px !important;
  269. }
  270. .shuru{border:1px solid #303030;border-radius: 10px;}
  271. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  272. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  273. .zuo image{width:60px;display: block;position: absolute}
  274. .you{border:1px solid #303030;border-radius: 10px;padding:10px;height: 300px;}
  275. /deep/ .you .grey-darken-5{
  276. background-color: #0d0d0d!important;
  277. padding: 0px !important;
  278. }
  279. /deep/ .you .text-red{color: white;}
  280. /deep/ .tan .active{background-color: #AAAAAA !important;}
  281. /deep/ .tan .tm-poups .grey-darken-5{background-color: gray !important;}
  282. /deep/ .tan uni-input{text-align: right;}
  283. /deep/ .you .border-grey-darken-4-b-1 {
  284. border-bottom: solid 1px #313131 !important;
  285. }
  286. /deep/ .tm--badges{position: absolute;top: 0px !important;right:6px;width: 18px;height: 18px;}
  287. .logincla{margin-top: 100px;}
  288. /deep/ .quindex uni-button{background-color: #0A84FF !important;}
  289. .error{height:18px !important;width: 18px !important;right: 3px !important;top:6px !important}
  290. </style>