index.vue 8.6 KB

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