index.vue 9.8 KB

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