center.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <view class="pages">
  3. <!-- <view class="" :style="{height: navHeight+'px' }"></view> -->
  4. <!-- <view class="page-bg">
  5. <img class="img" :src="staticUrl+'/img/center-index-bg.png'" alt="">
  6. </view> -->
  7. <view class="box">
  8. <view class="home_top">
  9. <view class="base-info block-wrap u-flex u-row-between" @click="$u.route('/center/memberinfo',{type:'redirectTo'})" v-if="vuex_member_info.name">
  10. <view class="left u-flex">
  11. <u-avatar :src="avatar||staticUrl+'/img/avatar.png'" size="140rpx"></u-avatar>
  12. <view class="info">
  13. <view class="name ellipsis-1">{{vuex_member_info.name||vuex_member_info.nickName}}</view>
  14. <view class="mobile u-flex">
  15. <text class="mobile">{{vuex_member_info.mobile|hidePhoneNumber}}</text>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- <u-icon @click="$u.route('/center/memberinfo',{type:'redirectTo'})" name="setting-fill" color="#333333" size="38rpx"></u-icon> -->
  20. </view>
  21. <view class="base-info block-wrap u-flex u-row-between" @click="goLogin" v-else>
  22. <view class="left u-flex">
  23. <u-avatar :src="staticUrl+'/img/avatar.png'" size="140rpx"></u-avatar>
  24. <view class="info">
  25. <view class="name ellipsis-1">登录/注册</view>
  26. <text class="mobile">登录查看更多</text>
  27. </view>
  28. </view>
  29. <!-- <u-icon name="setting-fill" color="#333333" size="38rpx"></u-icon> -->
  30. </view>
  31. </view>
  32. </view>
  33. <view class="tools block-wrap">
  34. <!-- <view class="title">常用工具</view> -->
  35. <view class="tools-wrap">
  36. <view class=""
  37. v-for="(item,index) in tools"
  38. @click="toolsClick(item)"
  39. :key="index">
  40. <view class="tool-item u-flex u-row-between" v-if="!item.chat">
  41. <view class="left u-flex">
  42. <u-icon :name="item.ico" color="#333333" size="55rpx"></u-icon>
  43. <text class="name">{{item.name}}</text>
  44. </view>
  45. <u-icon name="arrow-right" color="#ddd" size="40rpx"></u-icon>
  46. </view>
  47. <view class="tool-item" v-if="item.chat==1">
  48. <button class="button-item u-flex u-row-between" type="default" open-type="contact">
  49. <view class="left u-flex">
  50. <u-icon :name="item.ico" color="#333333" size="55rpx"></u-icon>
  51. <text class="name">{{item.name}}</text>
  52. </view>
  53. <u-icon name="arrow-right" color="#ddd" size="40rpx"></u-icon>
  54. </button>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <tabbar :tabbarIndexProps="2" />
  60. </view>
  61. </template>
  62. <script>
  63. import { systemInfo } from "@/mixin.js";
  64. import tabbar from "../components/tabbar.vue"
  65. export default {
  66. components:{
  67. tabbar
  68. },
  69. mixins:[systemInfo],
  70. data() {
  71. return {
  72. staticUrl:this.$commonConfig.staticUrl,
  73. avatar:this.$commonConfig.staticUrl+'/img/avatar.png',
  74. memberInfo:{},
  75. tools:[
  76. {name:'观看记录',url:'/center/viewrecord',ico:this.$commonConfig.staticUrl+'/img/center-record.png',checkauth:true},
  77. {name:'领券中心',url:'/center/mycoupon',ico:this.$commonConfig.staticUrl+'/img/center-coupon.png',checkauth:true},
  78. {name:'开具发票',url:'center/invoice',ico:this.$commonConfig.staticUrl+'/img/center-ticket.png',checkauth:true},
  79. // {name:'客服热线',url:'',ico:this.$commonConfig.staticUrl+'/img/center-call.png',checkauth:true,phone:'13682266542'},
  80. {name:'在线客服',chat:'1',ico:this.$commonConfig.staticUrl+'/img/center-call.png'},
  81. ]
  82. }
  83. },
  84. onShow() {
  85. if(this.vuex_member_info.name){
  86. this.getMemberInfo();
  87. }
  88. },
  89. onLoad() {
  90. this.getSystemInfo();
  91. },
  92. methods: {
  93. getMemberInfo(){
  94. this.$u.api.memberInfo({id:this.vuex_member_info.id}).then(res=>{
  95. this.memberInfo = res.data;
  96. this.avatar = res.data.avatar;
  97. this.$u.vuex('vuex_member_info', res.data);
  98. const isExist = this.tools.some(item => item.name === '实名认证');
  99. if(!res.data.isAuth&&!isExist){
  100. this.tools.push({name:'实名认证',url:'center/factorauth',ico:this.$commonConfig.staticUrl+'/img/center-ticket.png',checkauth:true})
  101. }
  102. // console.log('memberInfo',this.memberInfo);
  103. }).catch(err=>{
  104. console.log('memberInfo',err.data);
  105. })
  106. },
  107. toolsClick(item){
  108. let that = this;
  109. console.log('item',item);
  110. if(item.name!=='在线客服'){
  111. uni.showToast({
  112. title:'开发中',
  113. icon:"none"
  114. })
  115. return
  116. }
  117. if ('phone' in item) {
  118. if(!item.phone){
  119. uni.showToast({
  120. title:'电话号码为空',
  121. icon:"none"
  122. })
  123. return
  124. }
  125. uni.makePhoneCall({
  126. phoneNumber: item.phone,
  127. success() {
  128. console.log('success');
  129. },
  130. fail() {
  131. console.log('fail');
  132. }
  133. });
  134. return
  135. }
  136. if ('chat' in item) {
  137. return
  138. }
  139. console.log('item.checkauth',item.checkauth);
  140. if(item.checkauth){
  141. this.checkauth(item.url)
  142. }else{
  143. uni.$u.route(item.url);
  144. }
  145. },
  146. goLogin(){
  147. uni.setStorage({
  148. key: 'backUrl',
  149. data:'center/center' ,
  150. success: function () {
  151. uni.$u.route('/pages/login/login')
  152. }
  153. });
  154. },
  155. checkauth(pageUrl){
  156. if(this.vuex_member_info.name){
  157. uni.$u.route(pageUrl)
  158. }else{
  159. uni.showModal({
  160. title: '提示',
  161. content: '你需要登录后,才可使用此功能!',
  162. success: res => {
  163. if (res.confirm) {
  164. uni.setStorage({
  165. key: 'backUrl',
  166. data:pageUrl ,
  167. success: function () {
  168. uni.$u.route('/pages/login/login')
  169. }
  170. });
  171. }
  172. }
  173. })
  174. }
  175. }
  176. }
  177. }
  178. </script>
  179. <style>
  180. page{
  181. background-color: #fff;
  182. padding-top: 0;
  183. }
  184. </style>
  185. <style lang="scss" scoped>
  186. $boxHeight:418rpx;
  187. .box { width: 100%;height:$boxHeight; margin: auto; overflow: hidden; }
  188. .home_top {
  189. position: relative;
  190. width: 100%;
  191. height: $boxHeight;
  192. .base-info{
  193. position: absolute;
  194. left: 32rpx;
  195. right: 32rpx;
  196. bottom: 90rpx;
  197. color: #fff;
  198. }
  199. }
  200. .home_top:after { width: 180%; height: $boxHeight; position: absolute; left: -40%; top: 0; z-index: -1; content: ''; border-radius: 0 0 50% 50%; background: linear-gradient(180deg, #EE0C0C 0%, #F39D9F 100%); }
  201. .block-wrap{
  202. margin: 24rpx 32rpx;
  203. }
  204. .title{
  205. font-size: 32rpx;
  206. font-weight: 600;
  207. color: #333333;
  208. line-height: 45rpx;
  209. margin-bottom: 30rpx;
  210. }
  211. .base-info{
  212. margin-bottom: 10rpx;
  213. .info{
  214. margin-left: 30rpx;
  215. .name{
  216. font-size: 36rpx;
  217. font-weight: bold;
  218. color: #FFFFFF;
  219. line-height: 54rpx;
  220. margin-bottom: 10rpx;
  221. }
  222. .mobile{
  223. width: fit-content;
  224. font-size: 28rpx;
  225. font-weight: 400;
  226. color: #FFFFFF;
  227. line-height: 42rpx;
  228. }
  229. }
  230. }
  231. .tools{
  232. .tools-wrap{
  233. }
  234. .tool-item{
  235. padding: 12rpx 18rpx;
  236. background-color: #FBFBFB;
  237. margin-bottom: 20rpx;
  238. border-radius: 20rpx;
  239. overflow: hidden;
  240. .name{
  241. font-size: 32rpx;
  242. font-weight: 400;
  243. color: #363636;
  244. margin-left: 12rpx;
  245. }
  246. }
  247. .button-item{
  248. background-color: transparent;
  249. line-height: 1;
  250. font-size: 24rpx;
  251. font-weight: 400;
  252. color: #666666;
  253. border: 0;
  254. padding: 0;
  255. top: -2px;
  256. &::after{border: initial;}
  257. }
  258. }
  259. </style>