index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <view>
  3. <scroll-view scroll-y class="bg">
  4. <div class="user">
  5. <van-cell custom-class="head-cell" is-link label-class="" center>
  6. <view
  7. @click="
  8. () => {
  9. userFormShow = true;
  10. nickName = userInfo.nickName || '新用户';
  11. }
  12. "
  13. class="userButton"
  14. slot="title"
  15. >
  16. <image
  17. class="user-headImg"
  18. v-if="userInfo.headImage"
  19. :src="userInfo.headImage"
  20. ></image>
  21. <image class="user-headImg" v-else :src="unLoginHead"></image>
  22. <view
  23. class="flex"
  24. style="width: 60%; padding-left: 24rpx; text-align: left"
  25. >
  26. <view style="font-size: 38rpx; color: #0a1a33; width: 100%">{{
  27. userInfo.nickName || "新用户"
  28. }}</view>
  29. <view style="font-size: 26rpx; color: #8a9099; width: 100%">
  30. {{ userInfo.phone || "点击绑定手机号" }}</view
  31. >
  32. </view>
  33. </view>
  34. </van-cell>
  35. <van-cell
  36. title-class="uni-app-fontsize-paragraph"
  37. title="三力测试"
  38. is-link
  39. center
  40. url="/otherPages/beforeThreeExam/index"
  41. >
  42. </van-cell>
  43. <van-cell
  44. title-class="uni-app-fontsize-paragraph"
  45. title="关注公众号"
  46. is-link
  47. center
  48. url="/otherPages/careGzh/index"
  49. >
  50. </van-cell>
  51. <van-cell
  52. title-class="uni-app-fontsize-paragraph"
  53. title="电子资料"
  54. is-link
  55. @click="
  56. goPath(
  57. '/pages/extraWeb/index?src=https://nbjk-h5.zzxcx.net/pdfImages'
  58. )
  59. "
  60. center
  61. >
  62. </van-cell>
  63. <van-cell
  64. title-class="uni-app-fontsize-paragraph"
  65. title="每日驾考资讯"
  66. is-link
  67. center
  68. url="/otherPages/careEveryDay/index"
  69. >
  70. </van-cell>
  71. <van-cell
  72. title-class="uni-app-fontsize-paragraph"
  73. title="生成分享二维码"
  74. is-link
  75. center
  76. url="/otherPages/createReferCode/index"
  77. >
  78. </van-cell>
  79. <!-- <van-cell title="我要提现" value="" is-link center @click="goCashOut">
  80. </van-cell> -->
  81. <!-- <van-cell title="我的下级" value="" is-link center @click="goMyBranch">
  82. <template #icon>
  83. <m-icon type="hyyxq" class="cell-icon" />
  84. </template>
  85. </van-cell> -->
  86. <!-- <van-cell
  87. title="我的推广积分"
  88. value=""
  89. is-link
  90. center
  91. @click="goMyIntegral"
  92. >
  93. </van-cell> -->
  94. <!-- #ifdef MP-WEIXIN -->
  95. <!-- <van-cell
  96. title="会员有效期"
  97. :value="expireTime ? expireTime : '开通会员'"
  98. is-link
  99. center
  100. url="/otherPages/buyVip/index"
  101. >
  102. </van-cell> -->
  103. <!-- #endif -->
  104. <!-- #ifdef MP-TOUTIAO -->
  105. <van-cell
  106. v-if="!isVip"
  107. title="会员有效期"
  108. :value="'开通会员'"
  109. is-link
  110. center
  111. url="/otherPages/buyVip/index"
  112. >
  113. </van-cell>
  114. <van-cell
  115. v-if="isVip"
  116. title="会员有效期"
  117. :value="'已开通'"
  118. is-link
  119. center
  120. >
  121. </van-cell>
  122. <van-cell
  123. title="资料下载"
  124. is-link
  125. @click="goVipPath('/otherPages/pdfList/index')"
  126. left
  127. >
  128. <template #icon>
  129. <m-icon type="fkbz" class="cell-icon" />
  130. </template>
  131. </van-cell>
  132. <!-- #endif -->
  133. <!-- #ifdef MP-WEIXIN -->
  134. <!--
  135. <van-cell title-class="uni-app-fontsize-paragraph" title="反馈帮助" is-link center url="/pages/extraWeb/index?src=https://support.qq.com/product/359609">
  136. <template #icon>
  137. <m-icon type="fkbz" class="cell-icon" />
  138. </template>
  139. </van-cell> -->
  140. <!-- #endif -->
  141. </div>
  142. <view class="list"> </view>
  143. <view class="wxad">
  144. <ad
  145. ad-type="video"
  146. :ad-intervals="100"
  147. unit-id="adunit-8eb44bbd7e3147d4"
  148. ></ad>
  149. </view>
  150. <van-popup position="bottom" :show="userFormShow">
  151. <view class="userform">
  152. <view class="userform-close">
  153. <van-icon
  154. @click="
  155. () => {
  156. userFormShow = false;
  157. }
  158. "
  159. color="#a8a8a8"
  160. size="18"
  161. name="cross"
  162. />
  163. </view>
  164. <view>
  165. <van-field
  166. :value="userInfo.nickName"
  167. required
  168. clearable
  169. label="用户名"
  170. @change="changeUserName"
  171. placeholder="请输入用户名"
  172. />
  173. <van-field
  174. readonly
  175. :value="userInfo.phone"
  176. clearable
  177. label="手机号"
  178. placeholder="请绑定手机号"
  179. @change="changeUserPhone"
  180. >
  181. <van-button
  182. open-type="getPhoneNumber"
  183. @getphonenumber="getPhoneByUser"
  184. slot="button"
  185. size="small"
  186. type="primary"
  187. >
  188. 获取手机号
  189. </van-button>
  190. </van-field>
  191. </view>
  192. <view class="userform-bind">
  193. <van-button
  194. @click="sendUserInfo"
  195. custom-style="width:690rpx;"
  196. round
  197. type="primary"
  198. >修改用户信息</van-button
  199. >
  200. </view>
  201. </view>
  202. </van-popup>
  203. <!-- <view class="ad-box serviceBox">
  204. <ad unit-id="adunit-d8c1548cc9663765"></ad>
  205. </view> -->
  206. </scroll-view>
  207. </view>
  208. </template>
  209. <script>
  210. import api from "@/api/index";
  211. import unLoginHead from "@/assets/img/unLoginHead.png";
  212. export default {
  213. computed: {
  214. unLoginHead() {
  215. return unLoginHead;
  216. },
  217. expireTime() {
  218. return this.$store.state.user.userInfo.expireTime &&
  219. this.$store.getters.isVip
  220. ? this.$store.state.user.userInfo.expireTime.split(" ")[0]
  221. : null;
  222. },
  223. isVip() {
  224. return this.$store.getters.isVip;
  225. },
  226. },
  227. data() {
  228. return {
  229. userFormShow: false,
  230. userInfo: uni.getStorageSync("userInfo"),
  231. };
  232. },
  233. mounted() {
  234. this.$store.dispatch("GetInfo");
  235. },
  236. methods: {
  237. sendUserInfo() {
  238. api.user.userInfoUserInfo(this.userInfo).then((res) => {
  239. this.userFormShow = false;
  240. this.$store.dispatch("GetInfo");
  241. });
  242. },
  243. changeUserName(e) {
  244. console.log(e);
  245. this.userInfo.nickName = e.detail;
  246. },
  247. changeUserPhone(e) {
  248. console.log(e);
  249. this.userInfo.phone = e.detail;
  250. },
  251. getPhoneByUser(e) {
  252. api.user
  253. .userInfoGetPhoneByCode({
  254. code: e.detail.code,
  255. })
  256. .then((res) => {
  257. this.userInfo.phone = res.data;
  258. });
  259. },
  260. goPath(url) {
  261. uni.navigateTo({
  262. url,
  263. });
  264. },
  265. goVipPath(url) {
  266. if (this.isVip) {
  267. uni.navigateTo({
  268. url,
  269. });
  270. } else {
  271. uni.showToast({
  272. title: "vip才能使用",
  273. icon: "none",
  274. });
  275. }
  276. },
  277. getUserProfile(e) {
  278. let that = this;
  279. uni.getUserProfile({
  280. desc: "业务需要",
  281. success(res) {
  282. console.log(res);
  283. api.user
  284. .userInfoUserInfo({
  285. headImage: res.userInfo.avatarUrl,
  286. nickName: res.userInfo.nickName,
  287. })
  288. .then((res) => {
  289. that.$store.dispatch("GetInfo");
  290. });
  291. },
  292. });
  293. // let updateRes = await this.$api.user.updateUserInfo({
  294. // headImage: userInfo.userInfo.avatarUrl,
  295. // nickName: userInfo.userInfo.nickName,
  296. // });
  297. // if (updateRes.code == 200) {
  298. // this.$store.state.user.userInfo.headImage = userInfo.userInfo.avatarUrl;
  299. // this.$store.state.user.userInfo.nickName = userInfo.userInfo.nickName;
  300. // }
  301. },
  302. },
  303. };
  304. </script>
  305. <style>
  306. .user .head-cell {
  307. background: transparent;
  308. }
  309. </style>
  310. <style lang="scss" scoped>
  311. .userform {
  312. width: 100%;
  313. height: 450rpx;
  314. background: #fff;
  315. .userform-close {
  316. text-align: right;
  317. padding-right: 15rpx;
  318. padding-top: 15rpx;
  319. }
  320. .userform-bind {
  321. width: 100%;
  322. padding: 30rpx 30rpx;
  323. display: flex;
  324. justify-content: center;
  325. }
  326. }
  327. .flex {
  328. display: flex;
  329. flex-wrap: wrap;
  330. flex-direction: row;
  331. }
  332. .userButton::after {
  333. border: 0;
  334. }
  335. .userButton {
  336. border: 0;
  337. display: flex;
  338. flex-wrap: wrap;
  339. flex-direction: row;
  340. background: transparent;
  341. align-items: flex-start;
  342. height: auto;
  343. padding: 0;
  344. line-height: 1.4;
  345. }
  346. .bg {
  347. width: 100%;
  348. min-height: 812rpx;
  349. // background: #fff;
  350. background-image: url("https://ndata.zzxcx.net/ctjk/mp-wx/user/bg.png");
  351. }
  352. .list {
  353. padding: 0 15rpx;
  354. }
  355. .user {
  356. padding: 0 15rpx;
  357. /* height: 100vh; */
  358. .group {
  359. margin: 10px 0;
  360. }
  361. .user-avatar {
  362. width: 46px;
  363. height: 46px;
  364. margin-right: 10px;
  365. }
  366. }
  367. .user-headImg {
  368. width: 90rpx;
  369. height: 90rpx;
  370. border-radius: 50%;
  371. }
  372. .cell-icon {
  373. margin-right: 5px;
  374. }
  375. </style>