index.vue 8.3 KB

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