index.vue 8.5 KB

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