index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  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: 'subscribeList',
  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 == 'subscribeList') {
  187. // uni.navigateTo({
  188. // url: '/pagesMain/' + site.path
  189. // });
  190. try {
  191. uni.scanCode({
  192. onlyFromCamera: true,
  193. success: function (res) {
  194. uni.navigateTo({
  195. url: res.path
  196. })
  197. },
  198. fail: function (res) {
  199. this.$refs.uTips.show({
  200. title: "调用摄像头失败",
  201. type: 'warning',
  202. })
  203. },
  204. });
  205. } catch {
  206. this.$refs.uTips.show({
  207. title: "调用摄像头失败",
  208. type: 'warning',
  209. })
  210. }
  211. } else if(site.path == 'logout'){
  212. uni.removeStorageSync('token')
  213. uni.navigateTo({
  214. url: '/pages/login/index'
  215. });
  216. }else {
  217. console.log('/pagesMain/' + site.path);
  218. uni.navigateTo({
  219. url: '/pagesMain/' + site.path
  220. });
  221. }
  222. },
  223. // 分享
  224. share() {
  225. uni.share({
  226. provider: "weixin",
  227. scene: "WXSceneSession",
  228. type: 1,
  229. summary: "我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!",
  230. success: function(res) {
  231. console.log("success:" + JSON.stringify(res));
  232. },
  233. fail: function(err) {
  234. console.log("fail:" + JSON.stringify(err));
  235. }
  236. });
  237. },
  238. // 更换昵称头像
  239. changeWxInfo(info) {
  240. NET.request(API.changeWxInfo, {
  241. avatarUrl: info.target.userInfo.avatarUrl,
  242. nickName: info.target.userInfo.nickName,
  243. }, 'POST').then(res => {
  244. this.$refs.uTips.show({
  245. title: '设置成功',
  246. type: 'success',
  247. })
  248. this.userInfoShow = false
  249. uni.setStorage({
  250. key: 'userData',
  251. data: {
  252. ...uni.getStorageSync('userData'),
  253. headImage: res.data.avatarUrl,
  254. nickName: res.data.nickName,
  255. }
  256. })
  257. this.userData.headImage = res.data.avatarUrl
  258. this.userData.nickName = res.data.nickName
  259. }).catch(error => {
  260. this.$refs.uTips.show({
  261. title: error.message,
  262. type: 'warning',
  263. })
  264. })
  265. }
  266. }
  267. }
  268. </script>
  269. <style lang='scss'>
  270. @import "@/static/css/themes.scss";
  271. .content {
  272. width: 100%;
  273. height: 100vh;
  274. float: left;
  275. .user-info {
  276. width: 100%;
  277. height: 110px;
  278. float: left;
  279. .user-data {
  280. width: calc(100% - 110px);
  281. height: 110px;
  282. padding: 15px 0 15px 15px;
  283. float: left;
  284. .user-name {
  285. width: 100%;
  286. float: left;
  287. font-size: 24px;
  288. line-height: 30px;
  289. margin-top: 10px;
  290. white-space: nowrap;
  291. overflow: hidden;
  292. text-overflow: ellipsis;
  293. }
  294. .user-phone {
  295. width: 100%;
  296. color: #cccccc;
  297. line-height: 30px;
  298. float: left;
  299. white-space: nowrap;
  300. overflow: hidden;
  301. text-overflow: ellipsis;
  302. }
  303. }
  304. .user-img {
  305. width: 110px;
  306. height: 110px;
  307. padding: 15px;
  308. float: left;
  309. display: flex;
  310. align-items: center;
  311. justify-content: center;
  312. }
  313. }
  314. .member-box {
  315. white-space: nowrap;
  316. float: left;
  317. width: 100vw;
  318. height: 92px;
  319. .member-card {
  320. width: calc(100vw - 30px);
  321. display: inline-block;
  322. border-radius: 10px;
  323. background-color: $mainColor;
  324. padding: 15px;
  325. margin: 0 15px 20px 15px;
  326. position: relative;
  327. .member-info {
  328. width: calc(100% - 100px);
  329. float: left;
  330. .member-title {
  331. font-size: 18px;
  332. line-height: 20px;
  333. color: #FFFFFF;
  334. font-weight: bold;
  335. }
  336. .member-text {
  337. margin-top: 5px;
  338. line-height: 16px;
  339. color: #FFFFFF;
  340. }
  341. }
  342. .member-handle {
  343. width: 90px;
  344. height: 30px;
  345. margin-top: 6px;
  346. float: right;
  347. background-color: #FFFFFF;
  348. border-radius: 20px;
  349. font-size: 13px;
  350. color: $mainColor;
  351. text-align: center;
  352. font-weight: bold;
  353. line-height: 30px;
  354. }
  355. }
  356. }
  357. .user-handle {
  358. width: 100vw;
  359. height: 40px;
  360. float: left;
  361. padding: 0 15px;
  362. margin-bottom: 10px;
  363. display: flex;
  364. align-items: center;
  365. .handle-icon {
  366. width: 40px;
  367. height: 40px;
  368. text-align: center;
  369. line-height: 40px;
  370. display: flex;
  371. align-items: center;
  372. }
  373. .handle-label {
  374. height: 40px;
  375. flex: 1;
  376. margin-left: 10px;
  377. line-height: 40px;
  378. font-size: 15px;
  379. position: relative;
  380. }
  381. .handle-arrow {
  382. line-height: 40px;
  383. }
  384. .share-text {
  385. width: 100vw;
  386. padding: 0 65px;
  387. font-size: 16px;
  388. text-align: left;
  389. color: #303133;
  390. background-color: transparent;
  391. position: absolute;
  392. left: -65px;
  393. }
  394. .share-text:after {
  395. border: none;
  396. }
  397. }
  398. }
  399. </style>