center.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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}}</view>
  14. <view class="mobile u-flex">
  15. <text class="mobile">{{vuex_member_info.mobile}}</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.share">
  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.share==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/mycoupon',ico:this.$commonConfig.staticUrl+'/img/center-coupon.png',checkauth:false},
  77. {name:'开具发票',url:'center/invoice',ico:this.$commonConfig.staticUrl+'/img/center-ticket.png',checkauth:true},
  78. {name:'客服热线',url:'',ico:this.$commonConfig.staticUrl+'/img/center-call.png',checkauth:true,phone:'13682266542'},
  79. ]
  80. }
  81. },
  82. onShow() {
  83. if(this.vuex_member_info.name){
  84. this.getMemberInfo();
  85. }
  86. },
  87. onLoad() {
  88. this.getSystemInfo();
  89. },
  90. methods: {
  91. getMemberInfo(){
  92. this.$u.api.memberInfo({id:this.vuex_member_info.id}).then(res=>{
  93. this.memberInfo = res.data;
  94. this.avatar = res.data.avatar;
  95. this.$u.vuex('vuex_member_info', res.data);
  96. // console.log('memberInfo',this.memberInfo);
  97. }).catch(err=>{
  98. console.log('memberInfo',err.data);
  99. })
  100. },
  101. toolsClick(item){
  102. let that = this;
  103. console.log('item',item);
  104. if ('phone' in item) {
  105. if(!item.phone){
  106. uni.showToast({
  107. title:'电话号码为空',
  108. icon:"none"
  109. })
  110. return
  111. }
  112. uni.makePhoneCall({
  113. phoneNumber: item.phone,
  114. success() {
  115. console.log('success');
  116. },
  117. fail() {
  118. console.log('fail');
  119. }
  120. });
  121. return
  122. }
  123. if ('chat' in item) {
  124. return
  125. }
  126. if(item.checkauth){
  127. this.checkauth(item.url)
  128. }else{
  129. uni.$u.route(item.url);
  130. }
  131. },
  132. goLogin(){
  133. uni.setStorage({
  134. key: 'backUrl',
  135. data:'center/center' ,
  136. success: function () {
  137. uni.$u.route('/pages/login/login')
  138. }
  139. });
  140. },
  141. checkauth(pageUrl){
  142. if(this.vuex_member_info.name){
  143. uni.$u.route(pageUrl)
  144. }else{
  145. uni.showModal({
  146. title: '提示',
  147. content: '你需要登录后,才可使用此功能!',
  148. success: res => {
  149. if (res.confirm) {
  150. uni.setStorage({
  151. key: 'backUrl',
  152. data:pageUrl ,
  153. success: function () {
  154. uni.$u.route('/pages/login/login')
  155. }
  156. });
  157. }
  158. }
  159. })
  160. }
  161. }
  162. }
  163. }
  164. </script>
  165. <style>
  166. page{
  167. background-color: #fff;
  168. padding-top: 0;
  169. }
  170. </style>
  171. <style lang="scss" scoped>
  172. $boxHeight:418rpx;
  173. .box { width: 100%;height:$boxHeight; margin: auto; overflow: hidden; }
  174. .home_top {
  175. position: relative;
  176. width: 100%;
  177. height: $boxHeight;
  178. .base-info{
  179. position: absolute;
  180. left: 32rpx;
  181. right: 32rpx;
  182. bottom: 90rpx;
  183. color: #fff;
  184. }
  185. }
  186. .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%); }
  187. .block-wrap{
  188. margin: 24rpx 32rpx;
  189. }
  190. .title{
  191. font-size: 32rpx;
  192. font-weight: 600;
  193. color: #333333;
  194. line-height: 45rpx;
  195. margin-bottom: 30rpx;
  196. }
  197. .base-info{
  198. margin-bottom: 10rpx;
  199. .info{
  200. margin-left: 30rpx;
  201. .name{
  202. font-size: 36rpx;
  203. font-weight: bold;
  204. color: #FFFFFF;
  205. line-height: 54rpx;
  206. margin-bottom: 10rpx;
  207. }
  208. .mobile{
  209. width: fit-content;
  210. font-size: 28rpx;
  211. font-weight: 400;
  212. color: #FFFFFF;
  213. line-height: 42rpx;
  214. }
  215. }
  216. }
  217. .tools{
  218. .tools-wrap{
  219. }
  220. .tool-item{
  221. padding: 12rpx 18rpx;
  222. background-color: #FBFBFB;
  223. margin-bottom: 20rpx;
  224. border-radius: 20rpx;
  225. overflow: hidden;
  226. .name{
  227. font-size: 32rpx;
  228. font-weight: 400;
  229. color: #363636;
  230. margin-left: 12rpx;
  231. }
  232. }
  233. .button-item{
  234. background-color: transparent;
  235. line-height: 1;
  236. font-size: 24rpx;
  237. font-weight: 400;
  238. color: #666666;
  239. border: 0;
  240. padding: 0;
  241. top: -2px;
  242. &::after{border: initial;}
  243. }
  244. }
  245. </style>