index.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <view class="content">
  3. <view class="user-info">
  4. <view class="user-data">
  5. <view class="user-name">{{userData.nickName}}</view>
  6. <view class="user-phone">{{userData.phone}}</view>
  7. </view>
  8. <view class="user-img">
  9. <u-avatar :src="userData.headImage" size="160"></u-avatar>
  10. </view>
  11. </view>
  12. <scroll-view scroll-x class="member-box">
  13. <view class="member-card" @click="goToMemberCard()" v-if="memberInfo.status == 0">
  14. <view class="member-info">
  15. <view class="member-title">我的账号</view>
  16. <view class="member-text">您目前尚未开通会员</view>
  17. </view>
  18. <view class="member-handle">立即开通&nbsp;<u-icon name="arrow-right"></u-icon>
  19. </view>
  20. </view>
  21. <template v-else>
  22. <view class="member-card" @click="goToMemberCard(item)" v-for="(item, index) in studentList" :key="index">
  23. <view class="member-info">
  24. <view class="member-title">{{item.studentName}}</view>
  25. <view class="member-text">
  26. <view>剩余&nbsp;{{item.days}}&nbsp;天到期</view>
  27. </view>
  28. </view>
  29. <view class="member-handle">{{item.days === 0 ? '立即开通' : '立即续费'}}&nbsp;<u-icon name="arrow-right"></u-icon>
  30. </view>
  31. </view>
  32. </template>
  33. </scroll-view>
  34. <view class="user-handle" v-for="(item, index) in handleList" :key="index" @click="goToHandle(item)">
  35. <view class="handle-icon">
  36. <u-image :src="item.icon" mode="aspectFit" width="28px" height="28px"></u-image>
  37. </view>
  38. <view class="handle-label">
  39. <!-- <button type="primary" open-type="share" @click="share" v-if="item.path == 'share'" class="share-text">{{item.label}}</button> -->
  40. <text>{{item.label}}</text>
  41. </view>
  42. <view class="handle-arrow">
  43. <u-icon name="arrow-right" color="#cccccc" size="32"></u-icon>
  44. </view>
  45. </view>
  46. <u-modal v-model="userInfoShow" title="您没有上传头像" :show-confirm-button="false" :mask-close-able="true">
  47. <u-button type="default" :ripple="true" @getuserinfo="changeWxInfo" :custom-style="{...handleDefaultCustomStyle, marginLeft: '', marginTop: '20px'}"
  48. open-type="getUserInfo">点击一键上传</u-button>
  49. </u-modal>
  50. <u-top-tips ref="uTips"></u-top-tips>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. mapGetters
  56. } from 'vuex'
  57. const NET = require('@/utils/request')
  58. const API = require('@/config/api')
  59. export default {
  60. computed: {
  61. ...mapGetters([
  62. 'handleDefaultCustomStyle',
  63. ])
  64. },
  65. data() {
  66. return {
  67. userData: {
  68. headImage: '',
  69. userId: '',
  70. nickName: '',
  71. userName: '',
  72. phone: '',
  73. },
  74. userInfoShow: false,
  75. memberInfo: {
  76. lastDays: 0,
  77. status: 0,
  78. },
  79. handleList: [{
  80. label: '订单管理',
  81. path: 'orderList',
  82. icon: API.getServerImg + 'dingdanguanli.png'
  83. },
  84. {
  85. label: '学员信息',
  86. path: 'studentList',
  87. icon: API.getServerImg + 'xueyuanxinxi.png'
  88. },
  89. {
  90. label: '我的优惠券',
  91. path: 'couponList',
  92. icon: API.getServerImg + 'youhiquan.png'
  93. },
  94. {
  95. label: '分享有礼',
  96. path: 'shareInfo',
  97. icon: API.getServerImg + 'liwu.png'
  98. },
  99. {
  100. label: '我的评价',
  101. path: 'evaluateList',
  102. icon: API.getServerImg + 'pingjia.png'
  103. },
  104. {
  105. label: '预约体验记录',
  106. path: 'subscribeListAll',
  107. icon: API.getServerImg + 'yuyueList.png'
  108. },
  109. {
  110. label: '预约体验',
  111. path: 'subscribeList',
  112. icon: API.getServerImg + 'yuyue.png'
  113. },
  114. // {
  115. // label: '订阅通知',
  116. // path: 'sendMessage',
  117. // icon: API.getServerImg + 'yuyue.png'
  118. // },
  119. {
  120. label: '退出登录',
  121. path: 'logout',
  122. icon: API.getServerImg + 'tuichu.png'
  123. },
  124. ],
  125. studentList: [],
  126. templateList: []
  127. }
  128. },
  129. onLoad() {
  130. if (uni.getStorageSync('userData')) {
  131. this.userData = uni.getStorageSync('userData')
  132. }
  133. if (!this.userData.headImage || !this.userData.nickName) {
  134. this.userInfoShow = true
  135. }
  136. // 获取可购买会员卡学员列表
  137. NET.request(API.getAllStudentList, {}, 'POST').then(res => {
  138. this.studentList = res.data
  139. }).catch(error => {
  140. this.$refs.uTips.show({
  141. title: error.message,
  142. type: 'warning',
  143. })
  144. })
  145. // 获取我的账户
  146. NET.request(API.getMemberInfo, {}, 'POST').then(res => {
  147. this.memberInfo = res.data
  148. }).catch(error => {
  149. this.$refs.uTips.show({
  150. title: error.message,
  151. type: 'warning',
  152. })
  153. })
  154. // 获取订阅模板
  155. // NET.request(API.getTemplate, {}, 'POST').then(res => {
  156. // this.templateList = res.data || []
  157. // }).catch(error => {
  158. // this.$refs.uTips.show({
  159. // title: error.message,
  160. // type: 'warning',
  161. // })
  162. // })
  163. },
  164. methods: {
  165. // 跳转开通会员
  166. goToMemberCard(site) {
  167. // 跳转所有场馆页
  168. uni.navigateTo({
  169. url: '/pagesMember/venueMore'
  170. })
  171. // pagesMember/venueMore
  172. // uni.navigateTo({
  173. // url: '/pagesMain/memberCardList' + (this.memberInfo.status == 0 ? '' : '?studentId=' + site.studentId +
  174. // '&studentName=' + site.studentName + (site.venueId ? '&venueId=' + site.venueId + '&venueName=' + site.venueName :
  175. // ''))
  176. // });
  177. },
  178. // 跳转我的各列表界面
  179. goToHandle(site) {
  180. if (site.path == 'sendMessage') {
  181. wx.requestSubscribeMessage({
  182. tmplIds: this.templateList,
  183. success: (res) => {},
  184. fail: (error) => {
  185. // this.$refs.uTips.show({
  186. // title: '订阅失败:' + error.errMsg,
  187. // type: 'warning',
  188. // })
  189. },
  190. })
  191. } else if(site.path == 'subscribeList') {
  192. // uni.navigateTo({
  193. // url: '/pagesMain/' + site.path
  194. // });
  195. try {
  196. uni.scanCode({
  197. onlyFromCamera: true,
  198. success: function (res) {
  199. uni.navigateTo({
  200. url: res.path
  201. })
  202. },
  203. fail: function (res) {
  204. this.$refs.uTips.show({
  205. title: "调用摄像头失败",
  206. type: 'warning',
  207. })
  208. },
  209. });
  210. } catch {
  211. this.$refs.uTips.show({
  212. title: "调用摄像头失败",
  213. type: 'warning',
  214. })
  215. }
  216. } else if(site.path == 'logout'){
  217. uni.removeStorageSync('token')
  218. uni.navigateTo({
  219. url: '/pages/login/index'
  220. });
  221. }else {
  222. console.log('/pagesMain/' + site.path);
  223. uni.navigateTo({
  224. url: '/pagesMain/' + site.path
  225. });
  226. }
  227. },
  228. // 分享
  229. share() {
  230. uni.share({
  231. provider: "weixin",
  232. scene: "WXSceneSession",
  233. type: 1,
  234. summary: "我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!",
  235. success: function(res) {
  236. console.log("success:" + JSON.stringify(res));
  237. },
  238. fail: function(err) {
  239. console.log("fail:" + JSON.stringify(err));
  240. }
  241. });
  242. },
  243. // 更换昵称头像
  244. changeWxInfo(info) {
  245. NET.request(API.changeWxInfo, {
  246. avatarUrl: info.target.userInfo.avatarUrl,
  247. nickName: info.target.userInfo.nickName,
  248. }, 'POST').then(res => {
  249. this.$refs.uTips.show({
  250. title: '设置成功',
  251. type: 'success',
  252. })
  253. this.userInfoShow = false
  254. uni.setStorage({
  255. key: 'userData',
  256. data: {
  257. ...uni.getStorageSync('userData'),
  258. headImage: res.data.avatarUrl,
  259. nickName: res.data.nickName,
  260. }
  261. })
  262. this.userData.headImage = res.data.avatarUrl
  263. this.userData.nickName = res.data.nickName
  264. }).catch(error => {
  265. this.$refs.uTips.show({
  266. title: error.message,
  267. type: 'warning',
  268. })
  269. })
  270. }
  271. }
  272. }
  273. </script>
  274. <style lang='scss'>
  275. @import "@/static/css/themes.scss";
  276. .content {
  277. width: 100%;
  278. height: 100vh;
  279. float: left;
  280. .user-info {
  281. width: 100%;
  282. height: 110px;
  283. float: left;
  284. .user-data {
  285. width: calc(100% - 110px);
  286. height: 110px;
  287. padding: 15px 0 15px 15px;
  288. float: left;
  289. .user-name {
  290. width: 100%;
  291. float: left;
  292. font-size: 24px;
  293. line-height: 30px;
  294. margin-top: 10px;
  295. white-space: nowrap;
  296. overflow: hidden;
  297. text-overflow: ellipsis;
  298. }
  299. .user-phone {
  300. width: 100%;
  301. color: #cccccc;
  302. line-height: 30px;
  303. float: left;
  304. white-space: nowrap;
  305. overflow: hidden;
  306. text-overflow: ellipsis;
  307. }
  308. }
  309. .user-img {
  310. width: 110px;
  311. height: 110px;
  312. padding: 15px;
  313. float: left;
  314. display: flex;
  315. align-items: center;
  316. justify-content: center;
  317. }
  318. }
  319. .member-box {
  320. white-space: nowrap;
  321. float: left;
  322. width: 100vw;
  323. height: 92px;
  324. .member-card {
  325. width: calc(100vw - 30px);
  326. display: inline-block;
  327. border-radius: 10px;
  328. background-color: $mainColor;
  329. padding: 15px;
  330. margin: 0 15px 20px 15px;
  331. position: relative;
  332. .member-info {
  333. width: calc(100% - 100px);
  334. float: left;
  335. .member-title {
  336. font-size: 18px;
  337. line-height: 20px;
  338. color: #FFFFFF;
  339. font-weight: bold;
  340. }
  341. .member-text {
  342. margin-top: 5px;
  343. line-height: 16px;
  344. color: #FFFFFF;
  345. }
  346. }
  347. .member-handle {
  348. width: 90px;
  349. height: 30px;
  350. margin-top: 6px;
  351. float: right;
  352. background-color: #FFFFFF;
  353. border-radius: 20px;
  354. font-size: 13px;
  355. color: $mainColor;
  356. text-align: center;
  357. font-weight: bold;
  358. line-height: 30px;
  359. }
  360. }
  361. }
  362. .user-handle {
  363. width: 100vw;
  364. height: 40px;
  365. float: left;
  366. padding: 0 15px;
  367. margin-bottom: 10px;
  368. display: flex;
  369. align-items: center;
  370. .handle-icon {
  371. width: 40px;
  372. height: 40px;
  373. text-align: center;
  374. line-height: 40px;
  375. display: flex;
  376. align-items: center;
  377. }
  378. .handle-label {
  379. height: 40px;
  380. flex: 1;
  381. margin-left: 10px;
  382. line-height: 40px;
  383. font-size: 15px;
  384. position: relative;
  385. }
  386. .handle-arrow {
  387. line-height: 40px;
  388. }
  389. .share-text {
  390. width: 100vw;
  391. padding: 0 65px;
  392. font-size: 16px;
  393. text-align: left;
  394. color: #303133;
  395. background-color: transparent;
  396. position: absolute;
  397. left: -65px;
  398. }
  399. .share-text:after {
  400. border: none;
  401. }
  402. }
  403. }
  404. </style>