center.vue 6.6 KB

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