member-info.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <template>
  2. <view class="user-setting-box">
  3. <!-- #ifndef MP-TOUTIAO -->
  4. <Navbar background-color="#fff" color="#333" title="成员信息"></Navbar>
  5. <!-- #endif -->
  6. <view class="content">
  7. <view class="info-box top-border-radius top10">
  8. <view class="label">昵称</view>
  9. <view class="right">
  10. <!-- {{}} -->
  11. </view>
  12. </view>
  13. <view class="info-box">
  14. <view class="label">体重/kg</view>
  15. <view class="right">
  16. <input v-model="form.weight" type="text" class="input" placeholder="此处输入体重"/>
  17. </view>
  18. </view>
  19. <view class="info-box bottom-border-radius">
  20. <view class="label">时间</view>
  21. <view class="right">
  22. <!-- <uni-datetime-picker v-model="form.feedTime" :border="false" type="date" class="date"/> -->
  23. <uni-datetime-picker v-model="form.feedTime" :border="false" type="datetime" class="date-box">
  24. <view class="date">
  25. {{form.feedTime || '请选择时间'}}
  26. <IconText :code="`\ue88e`" class="icon" size="12" color="#C6C5CB"></IconText>
  27. </view>
  28. </uni-datetime-picker>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="fixed-bottom" >
  33. <view class="btn" @click="deleteBabyWeightModal" v-if="id">删除</view>
  34. <view class="solid-btn" @click="handleConfirm">保存</view>
  35. </view>
  36. <ShowModal ref="deletePopup" title="提示" @submit="deleteBabyWeight" leftBtnText="取消" content="是否确认删除?" btnText="确认" />
  37. </view>
  38. </template>
  39. <script lang="ts">
  40. import {
  41. Component,
  42. Mixins
  43. } from 'vue-property-decorator';
  44. import loginMixin from '@/common/mixins/loginMixin.ts';
  45. // import {
  46. // namespace
  47. // } from 'vuex-class';
  48. // const baseModule = namespace('base');
  49. @Component({})
  50. export default class UserSetting extends Mixins(loginMixin) {
  51. // @baseModule.Getter('_userInfo') _userInfo: any;
  52. form: any = {
  53. weight: null,
  54. height: null,
  55. feedTime: '',
  56. };
  57. bid: any = null;
  58. id: any = null;
  59. onShow() {
  60. }
  61. onLoad(){
  62. this.bid = +this.$Route.query.bid;
  63. if (this.$Route.query.id) {
  64. this.id = +this.$Route.query.id;
  65. this.getBabyWeightInfo();
  66. }
  67. }
  68. getBabyWeightInfo(){
  69. uni.showLoading({
  70. title: '加载中',
  71. });
  72. this.$http.get({
  73. url: this.$api.getBabyGrowthInfo,
  74. data: {
  75. id: this.id
  76. }
  77. }).then((res: any) => {
  78. for(let key in this.form){
  79. this.form[key] = res[key];
  80. }
  81. uni.hideLoading();
  82. })
  83. }
  84. deleteBabyWeightModal(){
  85. (this.$refs.deletePopup as any).open();
  86. }
  87. deleteBabyWeight(){
  88. uni.showLoading({
  89. title: '加载中',
  90. });
  91. this.$http.delete({
  92. url: this.$api.deleteBabyGrowth,
  93. data: {
  94. id: this.id
  95. }
  96. }).then((res: any) => {
  97. this.$Router.back(1);
  98. uni.hideLoading();
  99. })
  100. }
  101. handleConfirm(){
  102. console.log(this.form);
  103. uni.showLoading({
  104. title: '加载中',
  105. });
  106. let url : string = 'addBabyGrowth';
  107. let method : string = 'post';
  108. let data: any = {
  109. ...this.form,
  110. bid: this.bid,
  111. weight: +this.form.weight,
  112. height: +this.form.height,
  113. };
  114. if (this.id) {
  115. url = 'updateBabyGrowth';
  116. method = 'put';
  117. data.id = this.id;
  118. }
  119. this.$http[method]({
  120. url: this.$api[url],
  121. data: data
  122. }).then((res: any) => {
  123. this.$Router.back(1);
  124. uni.hideLoading();
  125. })
  126. }
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. page{
  131. background: #f5f5f5;
  132. }
  133. .user-setting-box {
  134. // background: #F5F5F5;
  135. height: 100vh;
  136. @include flex-y(flex-start);
  137. .content {
  138. width: 100%;
  139. flex: 1;
  140. // padding: 0 vw(10);
  141. box-sizing: border-box;
  142. @include flex-y(flex-start);
  143. .info-box{
  144. width: vw(355);
  145. height: vw(56);
  146. background: #fff;
  147. @include flex-x();
  148. padding-left: vw(20);
  149. padding-right: vw(10);
  150. box-sizing: border-box;
  151. @include word-vw(14, #333);
  152. margin-top: vw(1);
  153. &.top10{
  154. margin-top: vw(10);
  155. }
  156. &.top-border-radius{
  157. border-top-right-radius: vw(10);
  158. border-top-left-radius: vw(10);
  159. }
  160. &.bottom-border-radius{
  161. border-bottom-right-radius: vw(10);
  162. border-bottom-left-radius: vw(10);
  163. }
  164. .right{
  165. width: vw(210);
  166. @include flex-x(flex-end);
  167. .input{
  168. width: 100%;
  169. height: vw(40);
  170. border-radius: vw(5);
  171. background: #F6F6F6;
  172. text-align: center;
  173. font-size: vw(14);
  174. }
  175. /deep/.uni-date{
  176. @include flex-x(flex-end);
  177. }
  178. .date{
  179. // width: vw(100);
  180. @include flex-x(flex-end);
  181. .icon{
  182. margin-left: vw(3);
  183. }
  184. }
  185. }
  186. }
  187. }
  188. .fixed-bottom {
  189. height: vw(60);
  190. width: 100%;
  191. // background: #fff;
  192. @include flex-x(center);
  193. padding: 0 vw(15);
  194. box-sizing: border-box;
  195. .btn{
  196. @include solid-btn(125, 50, #787878);
  197. border-radius: vw(25);
  198. margin-right: vw(15);
  199. background: #fff;
  200. }
  201. .solid-btn {
  202. background: $bk-color;
  203. @include solid-btn(345, 50, #333);
  204. border-radius: vw(25);
  205. @include word-vw(14, #fff);
  206. flex: 1;
  207. }
  208. }
  209. }
  210. </style>