index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view :style="[mainStyle]">
  3. <view class="ttop" :style="'height:' + systems.barHeight + 'rpx;'">
  4. <view class="back"
  5. :style="'margin-top:' + systems.ktxStatusHeight + 'rpx;height:' + systems.navigationHeight + 'rpx;'"
  6. @click="back()">
  7. <image :src="picUrlss+'back_black.png'"></image>
  8. </view>
  9. </view>
  10. <view class="top">
  11. <view class="top-c">
  12. <view>您已开通健康卡,请完善健康档案</view>
  13. <image src="../static/images/dangan.png" class="dangan-img"></image>
  14. </view>
  15. </view>
  16. <view class="box" style="margin-top: -150rpx;z-index: 5;">
  17. <view class="tits ddflex">基本信息</view>
  18. <view class="form">
  19. <view class="li ddflex">
  20. <view class="label">姓名</view>
  21. <input v-model="name" placeholder="请填写真实姓名" placeholder-class="placeholder" class="ipt fflex" />
  22. </view>
  23. <view class="li ddflex">
  24. <view class="label">证件</view>
  25. <picker :range="idType" class="picker fflex" @change="changeType">
  26. <view v-if="typeIndex > -1">{{idType[typeIndex]}}</view>
  27. <view class="placeholder" v-else>请选择证件类型</view>
  28. <image src="../../static/pages/images/bico.png" class="bico"></image>
  29. </picker>
  30. </view>
  31. <view class="li ddflex">
  32. <view class="label">身份证号</view>
  33. <input type="idcard" maxlength="18" v-model="idcard" placeholder="输入身份证号码"
  34. placeholder-class="placeholder" class="ipt fflex" />
  35. </view>
  36. <view class="li ddflex">
  37. <view class="label">性别</view>
  38. <view class="gender ddflex fflex">
  39. <view class="lis ddflex" @click="checkGender(1)">
  40. <image :src="picUrlss+(gender == 1 ? 'lvluo/open_gou_h.png' : 'lvluo/open_gou.png')"
  41. class="gou"></image>男
  42. </view>
  43. <view class="lis ddflex" @click="checkGender(2)">
  44. <image :src="picUrlss+(gender == 2 ? 'lvluo/open_gou_h.png' : 'lvluo/open_gou.png')"
  45. class="gou"></image>女
  46. </view>
  47. </view>
  48. </view>
  49. <view class="li ddflex">
  50. <view class="label">手机号</view>
  51. <input type="number" maxlength="11" v-model="mobile" placeholder="输入接收通知的手机号"
  52. :disabled="isClickButton" placeholder-class="placeholder" class="ipt fflex" />
  53. <!-- #ifdef MP-WEIXIN -->
  54. <view v-if="!mobile" @click="limitIpt">
  55. <button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" hover-class="none"
  56. class="shou">授权</button>
  57. </view>
  58. <!-- #endif -->
  59. </view>
  60. </view>
  61. </view>
  62. <view class="box">
  63. <view class="tits ddflex">
  64. <view class="fflex">联系地址</view>
  65. <view class="edit ddflex" v-if="address"
  66. @click="jumpUrl('/mine/editAddress/editAddress?id=' + address.id+'&isOpen='+true)">修改<image
  67. src="../../static/pages/images/crico1.png"></image>
  68. </view>
  69. </view>
  70. <view class="addr ddflex" v-if="address">
  71. <image :src="picUrlss+'lvluo/open_dz.png'"></image>
  72. <view class="fflex">
  73. <view class="addr-dz">{{address.address}}
  74. <block v-if="address.house">{{address.house}}</block>
  75. </view>
  76. <view class="addr-info">{{address.name}}<text>{{address.phone}}</text></view>
  77. </view>
  78. </view>
  79. <view class="add-box" v-else>
  80. <!-- <view class="add" @click="chooseAddress">授权微信地址</view> -->
  81. <view class="add" @click="addOrUpdateAddress()">选择添加地址</view>
  82. </view>
  83. </view>
  84. <view style="height: 156rpx;"></view>
  85. <view class="bot">
  86. <view class="btn" @click="submit">保存</view>
  87. </view>
  88. </view>
  89. </template>
  90. <script>
  91. const app = getApp();
  92. const req = require("../../utils/request.js");
  93. const route = require('../../utils/route');
  94. const utils = require('../../utils/util.js');
  95. export default {
  96. data() {
  97. return {
  98. mainStyle: app.globalData.mainStyle,
  99. picUrlss: req.public.picUrls,
  100. systems: '',
  101. opt: {},
  102. sessionKey: '',
  103. userInfo: {},
  104. gender: 1,
  105. idType: ['身份证'],
  106. typeIndex: -1,
  107. name: '',
  108. idcard: '',
  109. mobile: '',
  110. address: '',
  111. isClickButton: false
  112. };
  113. },
  114. onLoad: function(options) {
  115. this.opt = options;
  116. this.getUserInfo();
  117. app.globalData.getCheckSessoin(json => {
  118. this.sessionKey = json.session_key;
  119. });
  120. },
  121. methods: {
  122. back() {
  123. uni.navigateBack();
  124. },
  125. changeType(e) {
  126. this.typeIndex = e.detail.value;
  127. },
  128. checkGender(gender) {
  129. this.gender = gender;
  130. },
  131. limitIpt() {
  132. this.isClickButton = true;
  133. },
  134. getPhoneNumber(event) {
  135. this.isClickButton = false;
  136. const _ts = this;
  137. const detail = event.detail;
  138. if (!detail || !detail.encryptedData || !detail.iv) return false;
  139. req.postRequest('/api/weixin/mobile', {
  140. encryptedData: detail.encryptedData,
  141. iv: detail.iv,
  142. sessionKey: _ts.sessionKey
  143. }, res => {
  144. let userInfo = req.getStorage('userInfo');
  145. userInfo.mobile = res.mobile;
  146. req.setStorage('userInfo', userInfo);
  147. _ts.mobile = res.mobile;
  148. });
  149. },
  150. chooseAddress() {
  151. let _ts = this;
  152. req.scopeAddress(data => {
  153. console.log('微信地址==', data)
  154. let region = [data.provinceName, data.cityName, data.countyName];
  155. let params = {
  156. address: data.provinceName + data.cityName + (data.countyName ? data.countyName : ''),
  157. isDefault: 1,
  158. name: data.userName,
  159. phone: data.telNumber,
  160. house: data.detailInfo,
  161. region: region.join(',')
  162. }
  163. this.saveAddress(params);
  164. });
  165. },
  166. saveAddress(params) {
  167. req.postRequest('/api/address/save', params, data => {
  168. this.address = data;
  169. })
  170. },
  171. addOrUpdateAddress() {
  172. let url = 'mine/addAddress/addAddress?isChoose=true';
  173. if (this.address && this.address.id) {
  174. url = 'mine/address/address?isChoose=true' + '&addressId=' + this.address
  175. .id;
  176. }
  177. app.globalData.openPage(url);
  178. },
  179. submit() {
  180. let that = this;
  181. let d = {
  182. realName: that.name,
  183. mobile: that.mobile,
  184. cardNo: that.idcard,
  185. gender: that.gender == 0 ? 1 : 2,
  186. address: that.address.house ? that.address.address + that.address.house : that.address.address
  187. };
  188. let reg = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/;
  189. if (!reg.test(d.realName)) return req.msg("请输入正确真实姓名(至少2位汉字)");
  190. if (!d.cardNo) return req.msg('请输入证件号码');
  191. let sfz = /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
  192. if (!sfz.test(d.cardNo)) return req.msg('请输入正确的证件号码');
  193. if (!d.mobile) return req.msg('请输入手机号');
  194. let isShowLoading = false;
  195. if (!isShowLoading) {
  196. req.loadIng('保存中');
  197. isShowLoading = true;
  198. }
  199. req.postRequest('/api/user/save', d, res => {
  200. uni.redirectTo({
  201. url: '/open/index/index'
  202. })
  203. // that.buy();
  204. });
  205. },
  206. //购买
  207. buy() {
  208. let that = this;
  209. route.vip({
  210. strategyId: this.opt.id,
  211. scene: req.getStorage('scene')
  212. },
  213. data => {
  214. route.vipPay(data.id, data.status, this.opt.money, res => {
  215. uni.hideLoading();
  216. if (res) {
  217. app.globalData.switchTab('pages/index/index');
  218. }
  219. });
  220. }
  221. );
  222. },
  223. getUserInfo() {
  224. req.getRequest('/api/user/info', {}, data => {
  225. this.userInfo = data;
  226. if (data.mobile) this.mobile = data.mobile;
  227. if (data.realName) this.name = data.realName;
  228. if (data.gender > 0) this.gender = data.gender;
  229. if (data.cardNo) {
  230. this.idcard = data.cardNo;
  231. this.typeIndex = 0;
  232. }
  233. })
  234. },
  235. jumpUrl(url) {
  236. uni.navigateTo({
  237. url: url
  238. })
  239. }
  240. },
  241. beforeMount() {
  242. const systemInfo = uni.getSystemInfoSync();
  243. console.log('systemInfo==', systemInfo)
  244. // px转换到rpx的比例
  245. let pxToRpxScale = 750 / systemInfo.windowWidth;
  246. this.pxToRpxScale = pxToRpxScale;
  247. let systems = {
  248. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  249. navigationHeight: 44 * pxToRpxScale, // 导航栏的高度
  250. };
  251. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  252. this.systems = systems;
  253. }
  254. };
  255. </script>
  256. <style>
  257. @import "./index.css"
  258. </style>