mine.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <view class="content">
  3. <view v-if="show">
  4. <authPhone v-on:watchShow='watchShow'></authPhone>
  5. </view>
  6. <view class="top_wrap">
  7. <view class="wrap">
  8. <view class="info_left">
  9. <open-data type="userAvatarUrl"></open-data>
  10. </view>
  11. <view class="info_right">
  12. <text>{{nickname}}</text>
  13. <text class="tel">{{tel}}</text>
  14. </view>
  15. <!-- <view class="tongbu" @click="tongbu">
  16. 同步用户信息
  17. </view> -->
  18. <view class='tongbu' type='primary' @click="wxGetUserInfo" v-if="tbShow==false">
  19. 同步用户信息
  20. </view>
  21. </view>
  22. <view class="stu_course">
  23. <u-cell-group class="course" >
  24. <u-cell-item class="course_item" title="学员课程" :title-style="{'font-size':'17px','font-weight':'bold'}"
  25. :border-bottom="false" @click="to_course">
  26. <view class="icon" slot="icon" size="52">
  27. <image src="../../static/course.png" mode=""></image>
  28. </view>
  29. </u-cell-item>
  30. </u-cell-group>
  31. </view>
  32. </view>
  33. <view class="item_wrap">
  34. <u-cell-group class="group">
  35. <u-cell-item class="item" title="私教记录" :arrow="false" :value="personal_training_nums" :value-style="{'font-size':'17px','font-weight':'bold','color':'#FF4600'}">
  36. <view class="icon" slot="icon" size="52">
  37. <image src="../../static/mine_item1.png" mode=""></image>
  38. </view>
  39. </u-cell-item>
  40. <u-cell-item class="item" title="培训班记录" :arrow="false" :value="course_nums" :value-style="{'font-size':'17px','font-weight':'bold','color':'#FF4600'}">
  41. <view class="icon" slot="icon" size="52">
  42. <image src="../../static/mine_item2.png" mode=""></image>
  43. </view>
  44. </u-cell-item>
  45. <u-cell-item class="item" title="学生信息" value="修改" :value-style="{'font-size':'14px','color':'#999999'}" @click="to_stuInfo">
  46. <view class="icon" slot="icon" size="52">
  47. <image src="../../static/mine_item3.png" mode=""></image>
  48. </view>
  49. </u-cell-item>
  50. <!-- <picker mode="selector" @change="location" :range="value">
  51. <u-cell-item class="item" :title="title" value="修改" :value-style="{'font-size':'14px','color':'#999999'}">
  52. <view class="icon" slot="icon" size="52">
  53. <image src="../../static/loc.png" mode=""></image>
  54. </view>
  55. </u-cell-item>
  56. </picker> -->
  57. </u-cell-group>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import authPhone from "../../components/authorize.vue"
  63. export default {
  64. components: {
  65. // 注册
  66. authPhone
  67. },
  68. data() {
  69. return {
  70. show: false,
  71. img_url: '',
  72. course_nums: '0次',
  73. personal_training_nums: '0次',
  74. tel: '12345678901',
  75. nickname: '啦啦啦啦',
  76. value: ['张', 2, 3],
  77. title: '马波尔儿童游泳馆',
  78. tbShow: false
  79. }
  80. },
  81. onShow() {
  82. uni.getSetting({
  83. success: (res) => {
  84. this.tbShow = res.authSetting['scope.userInfo']
  85. console.log(res.authSetting['scope.userInfo'],'授权')
  86. }
  87. // success(res)=>{
  88. //
  89. // }
  90. })
  91. if (this.vuex_is_auth == false || !this.vuex_is_auth) {
  92. this.show = true
  93. }
  94. },
  95. onLoad() {
  96. console.log(this, 'ppppp')
  97. let that = this
  98. this.getUser()
  99. // this.$u.post('/user', data).then(res => {
  100. //
  101. // })
  102. },
  103. methods: {
  104. //获取用户信息
  105. getUser() {
  106. this.$u.get('/user').then(res => {
  107. console.log(res, 'user')
  108. this.nickname = res.data.data.nickname
  109. let num = res.data.data.mobile
  110. if (num) {
  111. this.tel = num.substring(0, 3) + '****' + num.substring(7)
  112. }
  113. this.$u.get('/user/course-statistical').then(data => {
  114. console.log(data, 'mine')
  115. this.course_nums = data.data.course_nums + '次'
  116. this.personal_training_nums = data.data.personal_training_nums + '次'
  117. })
  118. this.$u.get('/shops').then(res => {
  119. this.value = []
  120. res.data.data.forEach(item => {
  121. this.value.push(item.name)
  122. })
  123. console.log(this.value, 'shops')
  124. })
  125. })
  126. },
  127. //同步用户信息
  128. wxGetUserInfo() {
  129. uni.getUserProfile({
  130. desc: '获取你的昵称、头像、地区及性别',
  131. success: res => {
  132. this.$u.post('/user/sync-info', res.userInfo).then(res => {
  133. if (res.code == 200) {
  134. uni.showToast({
  135. title: '同步成功',
  136. icon: 'none'
  137. })
  138. this.tbShow=false
  139. this.getUser()
  140. }
  141. })
  142. },
  143. fail: res => {
  144. console.log(2);
  145. console.log(res)
  146. //拒绝授权
  147. uni.showToast({
  148. title: '用户拒绝授权',
  149. icon: 'error',
  150. duration: 2000
  151. });
  152. return;
  153. }
  154. })
  155. // uni.getUserProfile({
  156. // success: (res) => {
  157. // console.log(res.userInfo,'用户信息');
  158. // // this.$u.post('/user/sync-info', res.userInfo).then(res=>{
  159. // // if(res.code==200){
  160. // // uni.showToast({
  161. // // title:'同步成功',
  162. // // icon:'none'
  163. // // })
  164. // // this.getUser()
  165. // // }
  166. // })
  167. // },
  168. // fail: () => {
  169. // console.log("未授权");
  170. // }
  171. // })
  172. },
  173. //监听子组件变化
  174. watchShow(value) {
  175. console.log(value, '姊川福')
  176. this.show = value
  177. },
  178. //跳转页面
  179. to_course() {
  180. uni.navigateTo({
  181. url: './stu-course'
  182. })
  183. },
  184. //私教记录
  185. to_record() {
  186. uni.navigateTo({
  187. url: './record'
  188. })
  189. },
  190. //培训班记录
  191. to_train() {
  192. uni.navigateTo({
  193. url: './train'
  194. })
  195. },
  196. to_stuInfo() {
  197. uni.navigateTo({
  198. url: './stu_info'
  199. })
  200. },
  201. location(e) {
  202. let index = e.detail.value
  203. this.title = this.value[index]
  204. console.log(e, 'this.value[e]')
  205. }
  206. }
  207. }
  208. </script>
  209. <style lang="scss">
  210. page {
  211. background-color: #F5F5F5;
  212. .content {
  213. .top_wrap {
  214. width: 100%;
  215. height: 195px;
  216. background: linear-gradient(90deg, #FF8F09, #FF3B21);
  217. position: relative;
  218. .tongbu {
  219. position: absolute;
  220. top: 40px;
  221. right: 0;
  222. background-color: #FFFFFF;
  223. border-radius: 22px 0 0 22px;
  224. height: 30px;
  225. line-height: 30px;
  226. font-size: 12px;
  227. color: #FF3B21;
  228. padding: 0 10px;
  229. }
  230. button::after {
  231. border: none !important;
  232. }
  233. .wrap {
  234. display: flex;
  235. padding-top: 38px;
  236. color: #ffffff;
  237. .info_left {
  238. width: 60px;
  239. height: 60px;
  240. border-radius: 50%;
  241. overflow: hidden;
  242. margin-left: 13px;
  243. image {
  244. width: 60px;
  245. height: 60px;
  246. }
  247. }
  248. .info_right {
  249. margin-left: 10px;
  250. text {
  251. display: block;
  252. font-size: 19px;
  253. font-weight: bold;
  254. }
  255. .tel {
  256. font-size: 16px;
  257. font-weight: normal;
  258. margin-top: 10px;
  259. }
  260. }
  261. }
  262. .stu_course {
  263. margin: 0 12px;
  264. // height: 84px;
  265. margin-top: 50px;
  266. overflow: hidden!important;
  267. border-radius: 8px!important;
  268. background-color: #fff;
  269. .course {
  270. height: 84px;
  271. }
  272. .course_item {
  273. height: 84px;
  274. }
  275. .icon {
  276. margin-left: 2px;
  277. margin-right: 16px;
  278. display: flex;
  279. align-items: center;
  280. image {
  281. width: 52px;
  282. height: 52px;
  283. }
  284. }
  285. }
  286. }
  287. .item_wrap {
  288. margin: 0 12px;
  289. border-radius: 8px;
  290. overflow: hidden;
  291. // top: 12px;
  292. margin-top: 42px;
  293. .group {
  294. width: 351px;
  295. height: 256px;
  296. .item {
  297. height: 64px;
  298. .icon {
  299. margin-right: 16px;
  300. image {
  301. width: 24px;
  302. height: 24px;
  303. }
  304. }
  305. }
  306. }
  307. }
  308. }
  309. }
  310. </style>