index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <view class="container">
  3. <view class="bg"></view>
  4. <view class="top-content">
  5. <!-- 这里是状态栏 -->
  6. <view class="status_bar" :style="{height: statusBarHeight}"></view>
  7. <view class="top-title">个人中心</view>
  8. </view>
  9. <view class="main-content" :style="{paddingTop: `calc(${statusBarHeight} + 88rpx)`}">
  10. <!-- 用户信息 -->
  11. <view class="user-info" @click="openPersonInfo()">
  12. <view class="head-img">
  13. <image :src="!user.avatar?'/static/images/detault_head.jpg':user.avatar" mode="aspectFill"></image>
  14. </view>
  15. <view class="name-phone">
  16. <view class="name">{{user.nickname || '请登录'}}</view>
  17. <view class="phone">ID:{{user.userId || user.id || user.phone || '暂无'}}</view>
  18. </view>
  19. </view>
  20. <!-- 菜单列表 -->
  21. <view class="menu-list">
  22. <view class="item" @click="navgetTo('/pages_shopping/shopping/myCoupon')">
  23. <view class="x-f">
  24. <view class="icon-bg">
  25. <image src="../../static/images/mycoupon.png" mode="aspectFit"></image>
  26. </view>
  27. <text class="text">优惠券</text>
  28. </view>
  29. <u-icon name="arrow-right" size="20" color="#CCCCCC"></u-icon>
  30. </view>
  31. <view class="item" @click="navgetTo('/pages_user/user/storeProductRelation')">
  32. <view class="x-f">
  33. <view class="icon-bg">
  34. <image src="../../static/images/icon_wdzj.png" mode="aspectFit"></image>
  35. </view>
  36. <text class="text">浏览记录</text>
  37. </view>
  38. <u-icon name="arrow-right" size="20" color="#CCCCCC"></u-icon>
  39. </view>
  40. <view class="item" @click="openH5(1)">
  41. <view class="x-f">
  42. <view class="icon-bg">
  43. <image src="../../static/images/icon_yhxy.png" mode="aspectFit"></image>
  44. </view>
  45. <text class="text">用户协议</text>
  46. </view>
  47. <u-icon name="arrow-right" size="20" color="#CCCCCC"></u-icon>
  48. </view>
  49. <view class="item" @click="openH5(2)">
  50. <view class="x-f">
  51. <view class="icon-bg">
  52. <image src="../../static/images/advice.png" mode="aspectFit"></image>
  53. </view>
  54. <text class="text">隐私保护</text>
  55. </view>
  56. <u-icon name="arrow-right" size="20" color="#CCCCCC"></u-icon>
  57. </view>
  58. <view class="item">
  59. <view class="x-f">
  60. <view class="icon-bg">
  61. <image src="../../static/images/customer1.png" mode="aspectFit"></image>
  62. </view>
  63. <text class="text">专属客服</text>
  64. <button class="contact-btn" open-type="contact"></button>
  65. </view>
  66. <u-icon name="arrow-right" size="20" color="#CCCCCC"></u-icon>
  67. </view>
  68. <view class="item" @click="navgetTo('/pages_user/user/personInfo')">
  69. <view class="x-f">
  70. <view class="icon-bg">
  71. <image src="../../static/images/icon-set.png" mode="aspectFit"></image>
  72. </view>
  73. <text class="text">个人信息</text>
  74. </view>
  75. <u-icon name="arrow-right" size="20" color="#CCCCCC"></u-icon>
  76. </view>
  77. </view>
  78. <!-- 退出登录 -->
  79. <view class="logout-box" v-if="isLogin">
  80. <view class="log-out" @click="loginOUt">退出登录</view>
  81. </view>
  82. </view>
  83. </view>
  84. </template>
  85. <script>
  86. import {getOrderCount} from '@/api/storeOrder'
  87. import {getUserInfo} from '@/api/user'
  88. // import likeProduct from '@/components/likeProduct.vue'
  89. export default {
  90. // components: {
  91. // likeProduct
  92. // },
  93. data() {
  94. return {
  95. count0:0,
  96. count1:0,
  97. count2:0,
  98. afterSalesCount:0,
  99. user:{
  100. isPromoter:0,
  101. isWeixinAuth:0,
  102. phone:"",
  103. nickname:"请登录",
  104. avatarUrl:"/static/images/detault_head.png"
  105. },
  106. // 状态栏的高度
  107. statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
  108. // 消息数量
  109. msgNum: 0,
  110. isShowMenu: 0,
  111. isLogin:false,
  112. };
  113. },
  114. onLoad() {
  115. this.isShowMenu = getApp().globalData.isShowMenu
  116. console.log("onload")
  117. },
  118. onShow() {
  119. console.log("onshow")
  120. var that=this;
  121. this.isLogin = this.utils.checkToken()
  122. if(this.isLogin) {
  123. that.getUserInfo();
  124. that.getOrderCount();
  125. }
  126. },
  127. onReachBottom() {
  128. console.log("onReachBottom")
  129. this.$refs.product.getGoodsProducts();
  130. },
  131. methods: {
  132. loginOUt(){
  133. this.utils.loginOut();
  134. this.user = {
  135. isPromoter:0,
  136. isWeixinAuth:0,
  137. phone:"",
  138. nickname:"请登录",
  139. avatarUrl:"/static/images/detault_head.png"
  140. },
  141. this.getUserInfo();
  142. },
  143. openPersonInfo(){
  144. this.utils.isLogin().then(res => {
  145. uni.navigateTo({
  146. url:"/pages_user/user/personInfo"
  147. })
  148. })
  149. },
  150. callService(){
  151. uni.makePhoneCall({
  152. phoneNumber:"4000717770",
  153. success:function(){
  154. console.log('拨打电话成功');
  155. },
  156. fail() {
  157. console.log('打电话失败了');
  158. }
  159. })
  160. },
  161. getOrderCount(){
  162. getOrderCount().then(
  163. res => {
  164. if(res.code==200){
  165. this.count0=res.count0;
  166. this.count1=res.count1;
  167. this.count2=res.count2;
  168. this.afterSalesCount=res.afterSalesCount;
  169. }
  170. },
  171. rej => {}
  172. );
  173. },
  174. toManager(){
  175. if(this.utils.checkCompanyUserLoginState()){
  176. uni.navigateTo({
  177. url: '/pages_company/index'
  178. })
  179. }
  180. else{
  181. uni.navigateTo({
  182. url: '/pages_company/auth/login'
  183. })
  184. }
  185. },
  186. openH5(type){
  187. var requestPath = uni.getStorageSync('requestPath');
  188. // uni.setStorageSync('url',requestPath+url);
  189. uni.navigateTo({
  190. url: '../home/h5?type='+type
  191. })
  192. },
  193. getUserInfo(){
  194. getUserInfo().then(
  195. res => {
  196. if(res.code==200){
  197. if(res.user!=null){
  198. this.isLogin=true;
  199. this.user=res.user;
  200. }
  201. else{
  202. this.utils.loginOut();
  203. }
  204. }else{
  205. uni.showToast({
  206. icon:'none',
  207. title: "请求失败",
  208. });
  209. }
  210. },
  211. rej => {}
  212. );
  213. },
  214. // 跳转页面
  215. navgetTo(url) {
  216. this.utils.isLogin().then(res => {
  217. if(res){
  218. uni.navigateTo({
  219. url: url
  220. })
  221. }
  222. })
  223. },
  224. // 查看订单
  225. showOrder(status) {
  226. uni.navigateTo({
  227. url: '/pages_user/user/storeOrder?status=' + status
  228. })
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="scss">
  234. page {
  235. background-color: #FFFFFF;
  236. }
  237. .container {
  238. min-height: 100vh;
  239. background-color: #FFFFFF;
  240. position: relative;
  241. .bg{
  242. width: 100%;
  243. height: 500rpx;
  244. position: absolute;
  245. background: linear-gradient(180deg, #DDF5E3 0%, #FFFFFF 100%);
  246. top: 0;
  247. left: 0;
  248. }
  249. }
  250. .top-content{
  251. width: 100%;
  252. position: fixed;
  253. top: 0;
  254. left: 0;
  255. z-index: 10;
  256. background-color: transparent;
  257. }
  258. .status_bar {
  259. width: 100%;
  260. background-color: transparent;
  261. }
  262. .top-title{
  263. height: 88upx;
  264. line-height: 88upx;
  265. font-size: 36upx;
  266. font-family: Source Han Sans CN;
  267. font-weight: bold;
  268. color: #333333;
  269. padding-left: 30upx;
  270. background-color: transparent;
  271. }
  272. .main-content {
  273. position: relative;
  274. z-index: 2;
  275. padding: 0 40rpx;
  276. }
  277. .user-info{
  278. display: flex;
  279. align-items: center;
  280. padding: 40upx 0 60upx 0;
  281. .head-img{
  282. width: 140upx;
  283. height: 140upx;
  284. border-radius: 50%;
  285. overflow: hidden;
  286. margin-right: 30upx;
  287. background-color: #f5f5f5;
  288. border: 4upx solid #FFFFFF;
  289. image{
  290. width: 100%;
  291. height: 100%;
  292. }
  293. }
  294. .name-phone{
  295. display: flex;
  296. flex-direction: column;
  297. justify-content: center;
  298. .name{
  299. font-size: 40upx;
  300. font-family: PingFang SC;
  301. font-weight: bold;
  302. color: #333333;
  303. line-height: 1.4;
  304. margin-bottom: 16rpx;
  305. }
  306. .phone{
  307. font-size: 26upx;
  308. font-family: PingFang SC;
  309. color: #999999;
  310. line-height: 1.4;
  311. }
  312. }
  313. }
  314. .menu-list{
  315. width: 100%;
  316. .item{
  317. box-sizing: border-box;
  318. display: flex;
  319. align-items: center;
  320. justify-content: space-between;
  321. padding: 30upx 0;
  322. position: relative;
  323. .x-f {
  324. display: flex;
  325. align-items: center;
  326. }
  327. .icon-bg {
  328. border-radius: 16rpx;
  329. display: flex;
  330. align-items: center;
  331. justify-content: center;
  332. margin-right: 24rpx;
  333. image {
  334. width: 72rpx;
  335. height: 72rpx;
  336. }
  337. }
  338. .text{
  339. font-family: PingFang SC;
  340. font-weight: 500;
  341. font-size: 30rpx;
  342. color: #333333;
  343. }
  344. .contact-btn{
  345. display: inline-block;
  346. position: absolute;
  347. top: 0;
  348. left: 0;
  349. width: 100%;
  350. height: 100%;
  351. opacity: 0;
  352. }
  353. }
  354. }
  355. .logout-box {
  356. margin-top: 60rpx;
  357. padding-bottom: 60rpx;
  358. .log-out{
  359. width: 100%;
  360. height: 88upx;
  361. line-height: 88upx;
  362. text-align: center;
  363. font-size: 30upx;
  364. font-family: PingFang SC;
  365. font-weight: 500;
  366. color: #666666;
  367. background: #FFFFFF;
  368. border: 2rpx solid #EEEEEE;
  369. border-radius: 44upx;
  370. }
  371. }
  372. </style>