index.vue 8.9 KB

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