index.vue 9.8 KB

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