金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

256 lines
6.7 KiB

  1. <template>
  2. <view>
  3. <lf-nav :spreadOut="true" :showIcon="true" bgColor="#F8F8F8" title="会员资料"></lf-nav>
  4. <view class="lf-font-26 lf-color-primary lf-p-30 lf-row-center">
  5. 尊敬的会员完善资料可以让我们为您提供更贴切的服务
  6. </view>
  7. <view class="lf-p-l-32 lf-p-r-32">
  8. <view class="set-tag lf-border-bottom">
  9. <view class="lf-font-28 lf-color-black">
  10. *姓名
  11. </view>
  12. <view class="lf-flex">
  13. <input type="text" class="edit-input" v-model="info.name" placeholder="请输入姓名" />
  14. </view>
  15. </view>
  16. </view>
  17. <!-- <view class="lf-p-l-32 lf-p-r-32">
  18. <view class="set-tag lf-border-bottom">
  19. <view class="lf-font-28 lf-color-black">
  20. 国籍
  21. </view>
  22. <view class="lf-flex">
  23. <input type="text" class="edit-input" v-model="info.native_place" placeholder="请输入你的国籍" />
  24. </view>
  25. </view>
  26. </view> -->
  27. <view class="lf-p-l-32 lf-p-r-32">
  28. <view class="set-tag lf-border-bottom">
  29. <view class="lf-font-28 lf-color-black">
  30. 性别
  31. </view>
  32. <view class="lf-flex">
  33. <input type="text" class="edit-input" :value="info.sex" :disabled="true" placeholder="未填写" />
  34. </view>
  35. </view>
  36. </view>
  37. <view class="lf-p-l-32 lf-p-r-32">
  38. <view class="set-tag lf-border-bottom">
  39. <view class="lf-font-28 lf-color-black">
  40. 出生日期
  41. </view>
  42. <view class="lf-flex">
  43. <input type="text" class="edit-input" :value="info.birthday" :disabled="true" placeholder="未填写" />
  44. </view>
  45. </view>
  46. </view>
  47. <view class="lf-p-l-32 lf-p-r-32">
  48. <view class="set-tag lf-border-bottom">
  49. <view class="lf-font-28 lf-color-black">
  50. 身份证号
  51. </view>
  52. <view class="lf-flex">
  53. <input type="text" class="edit-input" :value="info.id_number" :disabled="true" placeholder="未填写" />
  54. </view>
  55. </view>
  56. </view>
  57. <view class="lf-p-l-32 lf-p-r-32">
  58. <view class="set-tag lf-border-bottom">
  59. <view class="lf-font-28 lf-color-black">
  60. 通讯地址
  61. </view>
  62. <view class="lf-flex">
  63. <picker mode="region" :value="info.address" @change="addressChange" >
  64. <text class="address-picker">{{ info.address.join('') || '请选择' }}</text>
  65. </picker>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="lf-p-l-32 lf-p-r-32">
  70. <view class="set-tag lf-border-bottom">
  71. <view class="lf-font-28 lf-color-black"></view>
  72. <view class="lf-flex lf-w-100">
  73. <input type="text" class="edit-input lf-w-100" v-model="info.address_detail" placeholder="请输入您的详细地址" />
  74. </view>
  75. </view>
  76. </view>
  77. <!-- <view class="lf-p-l-32 lf-p-r-32">
  78. <view class="set-tag lf-border-bottom">
  79. <view class="lf-font-28 lf-color-black">
  80. 家庭地址
  81. </view>
  82. <view class="lf-flex">
  83. <input type="text" class="edit-input" v-model="info.home_address" placeholder="请输入您的家庭地址" />
  84. </view>
  85. </view>
  86. </view> -->
  87. <!-- <view class="lf-p-l-32 lf-p-r-32">
  88. <view class="set-tag lf-border-bottom">
  89. <view class="lf-font-28 lf-color-black">
  90. 学历
  91. </view>
  92. <view class="lf-flex">
  93. <input type="text" class="edit-input" v-model="info.education" placeholder="请输入您的学历" />
  94. </view>
  95. </view>
  96. </view> -->
  97. <view class="lf-font-26 lf-color-999 lf-p-30 lf-row-center">
  98. 温馨提示身份证号出生日期不支持线上修改如需修改请前往服务台办理
  99. </view>
  100. <button class="set-btn" hover-class="lf-opacity" @click="submit">保存</button>
  101. </view>
  102. </template>
  103. <script>
  104. export default {
  105. data() {
  106. return {
  107. info: {
  108. name: '',
  109. native_place: '',
  110. sex: '',
  111. birthday: '',
  112. id_number: '',
  113. address: [],
  114. address_detail: '',
  115. home_address: '',
  116. education: ''
  117. },
  118. token: ''
  119. }
  120. },
  121. onLoad(){
  122. var token = this.$cookieStorage.get('user_token');
  123. this.token = token;
  124. this.getMeInfo();
  125. },
  126. methods: {
  127. getMeInfo(){
  128. this.$http.get({
  129. api: 'api/me',
  130. header: {
  131. Authorization: this.token
  132. }
  133. }).then(res => {
  134. let detail = res.data.data;
  135. let info = this.info;
  136. info.name = detail.name;
  137. info.sex = detail.sex;
  138. info.birthday = detail.birthday;
  139. // info.native_place = detail.country;
  140. if(detail.province && detail.city && detail.area){
  141. let address = [detail.province, detail.city, detail.area];
  142. info.address = address;
  143. }
  144. info.address_detail = detail.postal_address;
  145. // info.home_address = detail.home_address;
  146. // todo 其他信息待补充... id_number身份证
  147. this.info = info;
  148. })
  149. },
  150. getValue(current, event){
  151. this[current +'_index'] = event.detail.value;
  152. },
  153. addressChange(event){
  154. this.info.address = event.detail.value;
  155. },
  156. submit(){
  157. let par = {};
  158. if(this.info.name){
  159. par.name = this.info.name; // 姓名
  160. }
  161. if(this.info.native_place){
  162. par.country = this.info.native_place; // 国籍
  163. }
  164. if(this.info.address.length){
  165. let address = this.info.address;
  166. par.province = address[0]; // 省
  167. par.city = address[1]; // 市
  168. par.area = address[2]; // 区
  169. }
  170. if(this.info.address_detail){
  171. par.postal_address = this.info.address_detail; // 通讯详细地址
  172. }
  173. if(this.info.home_address){
  174. par.home_address = this.info.home_address; // 家庭地址
  175. }
  176. if(this.info.education){
  177. par.education = this.info.education; // 学历
  178. }
  179. if(Object.keys(par).length <= 0){
  180. return this.$msg('您未填写资料哦', {icon: 'error'})
  181. }
  182. uni.showLoading({
  183. title: '正在保存中'
  184. });
  185. this.$http.post({
  186. api: 'api/users/update/info',
  187. data: par,
  188. header: {
  189. Authorization: this.token,
  190. Accept: 'application/json'
  191. }
  192. }).then(res => {
  193. uni.hideLoading();
  194. if(res.data.code == 200){
  195. this.$msg('保存成功', {icon: 'success'});
  196. }
  197. }).catch(err => {
  198. uni.hideLoading();
  199. this.$msg('保存失败', {icon: 'error'});
  200. })
  201. }
  202. }
  203. }
  204. </script>
  205. <style scoped lang="scss">
  206. // .input{
  207. // width: 400rpx;
  208. // text-align: right;
  209. // }
  210. .picker-w{
  211. width: 400rpx;
  212. text-align: right;
  213. }
  214. .set-btn {
  215. width: 550rpx;
  216. height: 100rpx;
  217. background: #15716E;
  218. border-radius: 50rpx;
  219. margin: 40rpx auto;
  220. font-size: 32rpx;
  221. color: white;
  222. line-height: 100rpx;
  223. }
  224. .edit-input {
  225. text-align: right;
  226. font-size: 28rpx;
  227. color: #777;
  228. }
  229. .set-tag {
  230. height: 100rpx;
  231. width: 100%;
  232. display: flex;
  233. align-items: center;
  234. justify-content: space-between;
  235. // border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  236. }
  237. .address-picker{
  238. font-size: 28rpx;
  239. color: #777777;
  240. display: inline-block;
  241. width: 400rpx;
  242. text-align: right;
  243. }
  244. /deep/.input-placeholder {
  245. font-size: 28rpx;
  246. color: #777;
  247. }
  248. </style>