index.vue 6.5 KB

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