index.vue 6.0 KB

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