index.vue 6.9 KB

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