user.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <view class="content">
  3. <view class="top">
  4. <view class="avabox">
  5. <van-image round class='img' width="200rpx" height="200rpx" :src="userData.headImage" />
  6. <view class="avatitbox">
  7. <text>{{userData.nickName}}</text>
  8. <text v-if="userData.gzptUserId">{{studentInfo.logincode}}</text>
  9. <view class="sync-btn" @tap='getUserProfile'>点击同步用户头像昵称</view>
  10. <!-- <text v-else @click="idCardShow=!idCardShow">未绑定身份证点击绑定</text> -->
  11. </view>
  12. </view>
  13. </view>
  14. <view class="serviceBox">
  15. <view class="tit">
  16. <text>我的服务</text>
  17. </view>
  18. <view class="btnBox">
  19. <button class="item-box" :plain='true' @click="goPage('/pages/user/order')">
  20. <van-icon name="/static/imgs/order-icon.png" size="22px" />
  21. <text class="text">我的订单</text>
  22. </button>
  23. <button class="item-box" :plain='true' @click="goPage('/pages/collectionList/index')">
  24. <van-icon name="/static/imgs/wdsc.png" size="22px" />
  25. <text class="text">我的收藏</text>
  26. </button>
  27. <button class="item-box" :plain='true' @click="goPage('/pages/browserecord/index')">
  28. <van-icon name="/static/imgs/llzj.png" size="22px" />
  29. <text class="text">浏览足迹</text>
  30. </button>
  31. <button class="item-box" :plain='true' open-type='feedback'>
  32. <van-icon name="/static/imgs/yjfk.png" size="22px" />
  33. <text class="text">意见反馈</text>
  34. </button>
  35. </view>
  36. </view>
  37. <view class="serviceBox">
  38. <view class="tit">
  39. <text>我的信息</text>
  40. </view>
  41. <van-cell title="我的设置" icon="/static/imgs/wdsz.png" is-link @tap="goPage('/pages/userset/index')" />
  42. <button class="server" open-type="contact" :plain='true'>
  43. <van-cell title="联系客服" icon="/static/imgs/lxkf.png" is-link />
  44. </button>
  45. </view>
  46. <view class="ad-box serviceBox">
  47. <ad unit-id="adunit-d8c1548cc9663765"></ad>
  48. </view>
  49. <van-popup :show="idCardShow" round>
  50. <view class="idCard">
  51. <van-divider contentPosition="center">绑定身份证信息</van-divider>
  52. <van-cell-group>
  53. <van-field :value="idCard" @change='idCardput' label="身份证" maxlength='18' placeholder="请输入身份证号" />
  54. <van-field :value="password" @change='passwordput' type="password" label="密码" placeholder="请输入密码" />
  55. <van-cell title="归属驾校地区" :value="area" @click='popup=!popup' />
  56. </van-cell-group>
  57. <view class="btn-box">
  58. <van-button @click='idCardShow=!idCardShow' type="default">取消绑定</van-button>
  59. <van-button @click='submitBinding' type="info" :loading='loading' loading-text="绑定中..">确认绑定</van-button>
  60. </view>
  61. </view>
  62. </van-popup>
  63. <van-popup :show="popup" position="bottom">
  64. <van-area :columns-placeholder="['请选择', '请选择']" value="35" @cancel='popup=!popup' @confirm='popup=!popup' :area-list="areaList"
  65. @change='regionSelection' columns-num='2' />
  66. </van-popup>
  67. </view>
  68. </template>
  69. <script>
  70. import square from '@/components/square/index.vue'
  71. import md5 from 'crypto-js/md5'
  72. import Toast from '@/wxcomponents/vant/toast/toast';
  73. import {
  74. login,
  75. getInfo,
  76. bindUserCard,
  77. updateUserInfo
  78. } from '@/api/login.js'
  79. import {
  80. getStudentInfo
  81. } from '@/api/studytime.js'
  82. export default {
  83. components: {
  84. square
  85. },
  86. data() {
  87. return {
  88. loading: false,
  89. idCardShow: false,
  90. popup: false,
  91. idCard: null,
  92. password: null,
  93. areaCode: null,
  94. area: "请点击选择地区",
  95. areaList: {
  96. province_list: {
  97. 35: '福建省',
  98. },
  99. city_list: {
  100. 3501: '福州市',
  101. 3502: '厦门市',
  102. 3503: '莆田市',
  103. 3504: '三明市',
  104. 3505: '泉州市',
  105. 3506: '漳州市',
  106. 3507: '南平市',
  107. 3508: '龙岩市',
  108. 3509: '宁德市',
  109. }
  110. }
  111. }
  112. },
  113. computed: {
  114. userData() {
  115. return this.$store.state.user.userInfo;
  116. }
  117. },
  118. mounted() {
  119. this.initUserInfo()
  120. },
  121. methods: {
  122. async initUserInfo() {
  123. await this.$store.dispatch('GetInfo')
  124. },
  125. idCardput(e) {
  126. this.idCard = e.detail
  127. },
  128. passwordput(e) {
  129. this.password = e.detail
  130. },
  131. submitBinding() {
  132. console.log(this.areaCode, this.idCard, this.password)
  133. this.loading = true
  134. bindUserCard({
  135. city: this.areaCode,
  136. logincode: this.idCard,
  137. password: md5(this.password).toString()
  138. }).then((res) => {
  139. if (res.code == 200) {
  140. Toast.success('绑定成功');
  141. this.idCardShow = false
  142. } else if (res.code == 502) {
  143. Toast.fail(res.msg);
  144. } else {
  145. Toast.fail('系统内部错误');
  146. }
  147. this.loading = false
  148. })
  149. },
  150. regionSelection(e) {
  151. console.log(e)
  152. this.area = `${e.detail.values[0].name} ${e.detail.values[1].name}`
  153. this.areaCode = e.detail.values[1].code
  154. },
  155. async getUserProfile(e) {
  156. let userInfo = await wx.getUserProfile({
  157. desc: '业务需要'
  158. })
  159. let updateRes = await updateUserInfo({
  160. headImage: userInfo.userInfo.avatarUrl,
  161. nickName: userInfo.userInfo.nickName
  162. })
  163. if (updateRes.code == 200) {
  164. // this.$store.dispatch('GetInfo')
  165. this.$store.state.user.userInfo.headImage=userInfo.userInfo.avatarUrl
  166. this.$store.state.user.userInfo.nickName=userInfo.userInfo.nickName
  167. }
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. .ad-box{
  174. margin: 40rpx;
  175. padding: 20rpx;
  176. display: flex;
  177. justify-content: center;
  178. align-items: center;
  179. }
  180. .server {
  181. border: none;
  182. background-color: none;
  183. margin: 0;
  184. padding: 0;
  185. text-align: left;
  186. display: flexbox;
  187. }
  188. .idCard {
  189. width: 600rpx;
  190. padding: 30rpx;
  191. margin: auto;
  192. display: flex;
  193. flex-direction: column;
  194. justify-content: center;
  195. align-items: center;
  196. }
  197. .btn-box {
  198. margin-top: 40rpx;
  199. width: 100%;
  200. display: flex;
  201. justify-content: space-between;
  202. }
  203. .content {}
  204. .top {
  205. padding-top: 100rpx;
  206. background-image: url("/static/imgs/bg.png");
  207. background-size: 100% 100%;
  208. background-repeat: no-repeat;
  209. .avabox {
  210. display: flex;
  211. padding: 10%;
  212. .img {
  213. border-radius: 50%;
  214. }
  215. .sync-btn {
  216. margin-top: 20rpx;
  217. height: 40rpx;
  218. }
  219. .avatitbox {
  220. flex: 1;
  221. display: flex;
  222. flex-direction: column;
  223. justify-content: space-between;
  224. padding: 30rpx;
  225. color: #FFFFFF;
  226. height: 100rpx;
  227. }
  228. }
  229. }
  230. .serviceBox {
  231. background-color: #fff;
  232. margin: 30rpx;
  233. border-radius: 10rpx;
  234. .tit {
  235. padding: 26rpx;
  236. border-bottom: 1rpx solid #E8E8E8;
  237. }
  238. .btnBox {
  239. display: flex;
  240. justify-content: space-between;
  241. align-items: center;
  242. .item-box {
  243. display: flex;
  244. flex-direction: column;
  245. justify-content: space-between;
  246. align-items: center;
  247. width: 200rpx;
  248. margin-top: 20rpx;
  249. padding: 20rpx;
  250. border: none;
  251. .text {
  252. font-size: 26rpx;
  253. font-family: PingFang SC;
  254. font-weight: 400;
  255. color: #666666;
  256. }
  257. }
  258. }
  259. }
  260. </style>