index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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">
  30. <tm-button v-if="id != ''" @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 :round="24" class="sao mb-40" style="margin-top: 50px;" @click="tijiao()" 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;
  67. this.reqData.weight=e.weight;
  68. this.reqData.height=e.height;
  69. this.reqData.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])
  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. quyifu(){
  84. uni.navigateTo({
  85. url: "/pages/luru/index",
  86. })
  87. },
  88. tijiao(){
  89. var that=this;
  90. if(this.reqData.username==""){
  91. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  92. return;
  93. }if(this.reqData.weight==""){
  94. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  95. return;
  96. }if(this.reqData.height==""){
  97. that.$refs.toast.show({model:'warn',label:'请将数据填写完整'})
  98. return;
  99. }
  100. if(this.reqData.body_arr.length !=0){
  101. this.reqData.body_type=this.reqData.body_arr[0].id;
  102. }
  103. if(that.id){
  104. this.reqData.id=that.id;
  105. var url="/api/MemberInfo/updateMemberInfo";
  106. }else{
  107. var url="/api/MemberInfo/addOneMemberInfo";
  108. }
  109. myRequest({
  110. url:url ,
  111. method:'post',
  112. data:that.reqData
  113. }).then(res => {
  114. console.log(res.data)
  115. if (res.data.code == 200) {
  116. let pages = getCurrentPages(); // 当前页面
  117. let beforePage = pages[pages.length - 2]; // 前一个页面
  118. uni.navigateBack({
  119. delta: 1,
  120. success: function() {
  121. beforePage.$vm.getDate()
  122. }
  123. });
  124. }else{
  125. that.$refs.toast.show({model:'error',label:res.data.msg})
  126. }
  127. })
  128. },
  129. quxiao(){
  130. var that=this;
  131. myRequest({
  132. url: "/api/MemberInfo/deleteMemberInfo",
  133. method:'post',
  134. data:{id:that.id}
  135. }).then(res => {
  136. console.log(res.data)
  137. if (res.data.code == 200) {
  138. let pages = getCurrentPages(); // 当前页面
  139. let beforePage = pages[pages.length - 2]; // 前一个页面
  140. uni.navigateBack({
  141. delta: 1,
  142. success: function() {
  143. beforePage.$vm.getDate()
  144. }
  145. });
  146. }else{
  147. that.$refs.toast.show({model:'error',label:res.data.msg})
  148. }
  149. })
  150. },
  151. obTstr2(o){
  152. if(Array.isArray(o)){
  153. if(o.length.length===0) return "";
  154. return o[0]?.title??""
  155. }
  156. return ''
  157. },
  158. saoma(){
  159. var that=this;
  160. uni.scanCode({
  161. scanType: ['barCode'],
  162. success: function (res) {
  163. console.log('条码类型:' + res.scanType);
  164. console.log('条码内容:' + res.result);
  165. that.reqData.wardrode_no=res.result;
  166. that.active=2;
  167. },
  168. error : function(e) {
  169. alert("网络异常,请重试");
  170. }
  171. })
  172. },
  173. chuangjianFun(){
  174. var that=this;
  175. if(that.reqData.familyname==""){
  176. that.$refs.toast.show({model:'warn',label:'请输入家庭名称'})
  177. return
  178. }
  179. that.active=3;
  180. }
  181. },
  182. }
  183. </script>
  184. <style lang="scss">
  185. .zhanshi{
  186. width: 100%;
  187. margin: 0 auto;
  188. margin-top: 10px;
  189. margin-bottom: 40px;
  190. }
  191. /deep/ .tm-menubars .body{
  192. background-color: #1b1b1b !important;
  193. }
  194. /deep/ .kuang{margin:0 !important;padding: 14px !important;margin-bottom: 40px !important;}
  195. .jindu{width: 90%;margin: 0 auto;display: block;}
  196. .wenzi{width: 94%;margin: 0 auto;}
  197. .nicheng{width: 130px;height:132px;display: block;margin:0 auto;margin-top: 50px;}
  198. /deep/ .shuru .grey-darken-5{
  199. background-color: #0d0d0d!important;
  200. padding: 0px !important;
  201. }
  202. .shuru{border:1px solid #303030;border-radius: 10px;}
  203. /deep/ .shuru .text-primary.bk{color:#303030 !important;}
  204. /deep/ .shuru .border-grey-darken-4-b-1{border-bottom:none !important;}
  205. .zuo image{width:60px;display: block;}
  206. .you{border:1px solid #303030;border-radius: 10px;padding:10px;height: 300px;}
  207. /deep/ .you .grey-darken-5{
  208. background-color: #0d0d0d!important;
  209. padding: 0px !important;
  210. }
  211. /deep/ .you .text-red{color: white;}
  212. /deep/ .tan .active{background-color: #AAAAAA !important;}
  213. /deep/ .tan .tm-poups .grey-darken-5{background-color: gray !important;}
  214. /deep/ .tan uni-input{text-align: right;}
  215. /deep/ .you .border-grey-darken-4-b-1 {
  216. border-bottom: solid 1px #313131 !important;
  217. }
  218. /deep/ .tm--badges{position: absolute;top: 0px;right:6px}
  219. .logincla{margin-top: 100px;}
  220. /deep/ .quindex uni-button{background-color: #0A84FF !important;}
  221. .anniu{width: 80%;margin: 0 auto;margin-top: 20px;}
  222. /deep/ .anniu .gray.bk{color: white !important;}
  223. </style>