index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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: 'leaveRecord',
  107. icon: API.getServerImg + 'yuyueList.png'
  108. },
  109. {
  110. label: '预约体验记录',
  111. path: 'subscribeListAll',
  112. icon: API.getServerImg + 'yuyueList.png'
  113. },
  114. {
  115. label: '预约体验',
  116. path: 'subscribeList',
  117. icon: API.getServerImg + 'yuyue.png'
  118. },
  119. // {
  120. // label: '订阅通知',
  121. // path: 'sendMessage',
  122. // icon: API.getServerImg + 'yuyue.png'
  123. // },
  124. {
  125. label: '退出登录',
  126. path: 'logout',
  127. icon: API.getServerImg + 'tuichu.png'
  128. },
  129. ],
  130. studentList: [],
  131. templateList: []
  132. }
  133. },
  134. onLoad() {
  135. if (uni.getStorageSync('userData')) {
  136. this.userData = uni.getStorageSync('userData')
  137. }
  138. if (!this.userData.headImage || !this.userData.nickName) {
  139. this.userInfoShow = true
  140. }
  141. // 获取可购买会员卡学员列表
  142. NET.request(API.getAllStudentList, {}, 'POST').then(res => {
  143. this.studentList = res.data
  144. }).catch(error => {
  145. this.$refs.uTips.show({
  146. title: error.message,
  147. type: 'warning',
  148. })
  149. })
  150. // 获取我的账户
  151. NET.request(API.getMemberInfo, {}, 'POST').then(res => {
  152. this.memberInfo = res.data
  153. }).catch(error => {
  154. this.$refs.uTips.show({
  155. title: error.message,
  156. type: 'warning',
  157. })
  158. })
  159. // 获取订阅模板
  160. // NET.request(API.getTemplate, {}, 'POST').then(res => {
  161. // this.templateList = res.data || []
  162. // }).catch(error => {
  163. // this.$refs.uTips.show({
  164. // title: error.message,
  165. // type: 'warning',
  166. // })
  167. // })
  168. },
  169. methods: {
  170. // 跳转开通会员
  171. goToMemberCard(site) {
  172. // 跳转所有场馆页
  173. uni.navigateTo({
  174. url: '/pagesMember/venueMore'
  175. })
  176. // pagesMember/venueMore
  177. // uni.navigateTo({
  178. // url: '/pagesMain/memberCardList' + (this.memberInfo.status == 0 ? '' : '?studentId=' + site.studentId +
  179. // '&studentName=' + site.studentName + (site.venueId ? '&venueId=' + site.venueId + '&venueName=' + site.venueName :
  180. // ''))
  181. // });
  182. },
  183. // 跳转我的各列表界面
  184. goToHandle(site) {
  185. if (site.path == 'sendMessage') {
  186. wx.requestSubscribeMessage({
  187. tmplIds: this.templateList,
  188. success: (res) => {},
  189. fail: (error) => {
  190. // this.$refs.uTips.show({
  191. // title: '订阅失败:' + error.errMsg,
  192. // type: 'warning',
  193. // })
  194. },
  195. })
  196. } else if(site.path == 'subscribeList') {
  197. // uni.navigateTo({
  198. // url: '/pagesMain/' + site.path
  199. // });
  200. try {
  201. uni.scanCode({
  202. onlyFromCamera: true,
  203. success: function (res) {
  204. uni.navigateTo({
  205. url: res.path
  206. })
  207. },
  208. fail: function (res) {
  209. this.$refs.uTips.show({
  210. title: "调用摄像头失败",
  211. type: 'warning',
  212. })
  213. },
  214. });
  215. } catch {
  216. this.$refs.uTips.show({
  217. title: "调用摄像头失败",
  218. type: 'warning',
  219. })
  220. }
  221. } else if(site.path == 'logout'){
  222. uni.removeStorageSync('token')
  223. uni.navigateTo({
  224. url: '/pages/login/index'
  225. });
  226. }else {
  227. console.log('/pagesMain/' + site.path);
  228. uni.navigateTo({
  229. url: '/pagesMain/' + site.path
  230. });
  231. }
  232. },
  233. // 分享
  234. share() {
  235. uni.share({
  236. provider: "weixin",
  237. scene: "WXSceneSession",
  238. type: 1,
  239. summary: "我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!",
  240. success: function(res) {
  241. console.log("success:" + JSON.stringify(res));
  242. },
  243. fail: function(err) {
  244. console.log("fail:" + JSON.stringify(err));
  245. }
  246. });
  247. },
  248. // 更换昵称头像
  249. changeWxInfo(info) {
  250. NET.request(API.changeWxInfo, {
  251. avatarUrl: info.target.userInfo.avatarUrl,
  252. nickName: info.target.userInfo.nickName,
  253. }, 'POST').then(res => {
  254. this.$refs.uTips.show({
  255. title: '设置成功',
  256. type: 'success',
  257. })
  258. this.userInfoShow = false
  259. uni.setStorage({
  260. key: 'userData',
  261. data: {
  262. ...uni.getStorageSync('userData'),
  263. headImage: res.data.avatarUrl,
  264. nickName: res.data.nickName,
  265. }
  266. })
  267. this.userData.headImage = res.data.avatarUrl
  268. this.userData.nickName = res.data.nickName
  269. }).catch(error => {
  270. this.$refs.uTips.show({
  271. title: error.message,
  272. type: 'warning',
  273. })
  274. })
  275. }
  276. }
  277. }
  278. </script>
  279. <style lang='scss'>
  280. @import "@/static/css/themes.scss";
  281. .content {
  282. width: 100%;
  283. height: 100vh;
  284. float: left;
  285. .user-info {
  286. width: 100%;
  287. height: 110px;
  288. float: left;
  289. .user-data {
  290. width: calc(100% - 110px);
  291. height: 110px;
  292. padding: 15px 0 15px 15px;
  293. float: left;
  294. .user-name {
  295. width: 100%;
  296. float: left;
  297. font-size: 24px;
  298. line-height: 30px;
  299. margin-top: 10px;
  300. white-space: nowrap;
  301. overflow: hidden;
  302. text-overflow: ellipsis;
  303. }
  304. .user-phone {
  305. width: 100%;
  306. color: #cccccc;
  307. line-height: 30px;
  308. float: left;
  309. white-space: nowrap;
  310. overflow: hidden;
  311. text-overflow: ellipsis;
  312. }
  313. }
  314. .user-img {
  315. width: 110px;
  316. height: 110px;
  317. padding: 15px;
  318. float: left;
  319. display: flex;
  320. align-items: center;
  321. justify-content: center;
  322. }
  323. }
  324. .member-box {
  325. white-space: nowrap;
  326. float: left;
  327. width: 100vw;
  328. height: 92px;
  329. .member-card {
  330. width: calc(100vw - 30px);
  331. display: inline-block;
  332. border-radius: 10px;
  333. background-color: $mainColor;
  334. padding: 15px;
  335. margin: 0 15px 20px 15px;
  336. position: relative;
  337. .member-info {
  338. width: calc(100% - 100px);
  339. float: left;
  340. .member-title {
  341. font-size: 18px;
  342. line-height: 20px;
  343. color: #FFFFFF;
  344. font-weight: bold;
  345. }
  346. .member-text {
  347. margin-top: 5px;
  348. line-height: 16px;
  349. color: #FFFFFF;
  350. }
  351. }
  352. .member-handle {
  353. width: 90px;
  354. height: 30px;
  355. margin-top: 6px;
  356. float: right;
  357. background-color: #FFFFFF;
  358. border-radius: 20px;
  359. font-size: 13px;
  360. color: $mainColor;
  361. text-align: center;
  362. font-weight: bold;
  363. line-height: 30px;
  364. }
  365. }
  366. }
  367. .user-handle {
  368. width: 100vw;
  369. height: 40px;
  370. float: left;
  371. padding: 0 15px;
  372. margin-bottom: 10px;
  373. display: flex;
  374. align-items: center;
  375. .handle-icon {
  376. width: 40px;
  377. height: 40px;
  378. text-align: center;
  379. line-height: 40px;
  380. display: flex;
  381. align-items: center;
  382. }
  383. .handle-label {
  384. height: 40px;
  385. flex: 1;
  386. margin-left: 10px;
  387. line-height: 40px;
  388. font-size: 15px;
  389. position: relative;
  390. }
  391. .handle-arrow {
  392. line-height: 40px;
  393. }
  394. .share-text {
  395. width: 100vw;
  396. padding: 0 65px;
  397. font-size: 16px;
  398. text-align: left;
  399. color: #303133;
  400. background-color: transparent;
  401. position: absolute;
  402. left: -65px;
  403. }
  404. .share-text:after {
  405. border: none;
  406. }
  407. }
  408. }
  409. </style>