index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <template>
  2. <view class="content">
  3. <view class="main-bg"></view>
  4. <view class="page-content">
  5. <view class="user-info-box" @click="gologin" v-if="!userData.userName">
  6. <image class="user-image" src="@/static/images/userDefaultHead.png" mode="widthFix"></image>
  7. <view class="user-info">
  8. <view class="user-logoin-title">点击登录</view>
  9. <view class="user-logoin-lable">登录后享受更多权益~</view>
  10. </view>
  11. </view>
  12. <view class="user-info-box" v-else>
  13. <image class="user-image" :src="userData.headImage" mode="widthFix" style="border-radius: 50%;"></image>
  14. <view class="user-info">
  15. <view class="user-logoin-title mb5">{{userData.userName}}</view>
  16. <view class="user-level" v-if="mainInfo.flag">
  17. <view class="iconfont iconVIP mr5"></view>
  18. <view>VIP用户</view>
  19. </view>
  20. </view>
  21. <image class="user-info-right" src="" mode=""></image>
  22. </view>
  23. <view class="user-activity">
  24. <view class="mr20" @click="entrustClick()">
  25. <view class="font18">{{mainInfo.entrustNo ? mainInfo.entrustNo : 0}}</view>
  26. <view class="font10">共享种植</view>
  27. </view>
  28. <view class="mr20">|</view>
  29. <view class="mr20" @click="integralClick()">
  30. <view class="font18">{{mainInfo.totalIntegral ? mainInfo.totalIntegral : 0}}</view>
  31. <view class="font10">我的积分</view>
  32. </view>
  33. <view class="mr20">|</view>
  34. <view @click="couponClick()">
  35. <view class="font18">{{mainInfo.memberCouponNo ? mainInfo.memberCouponNo : 0}}</view>
  36. <view class="font10">我的优惠券</view>
  37. </view>
  38. </view>
  39. <view class="order-box">
  40. <view class="order-item" @click="orderClick(2)">
  41. <view class="iconfont icondaifukuan order-item-icon">
  42. <view v-if="num.unPay" class="order-item-icon-num">{{num.unPay < 99 ? num.unPay : '99+'}}</view>
  43. </view>
  44. <view class="order-item-text">待付款</view>
  45. </view>
  46. <view class="order-item" @click="orderClick(3)">
  47. <view class="iconfont icondaifahuo order-item-icon">
  48. <view v-if="num.unSend" class="order-item-icon-num">{{num.unSend < 99 ? num.unSend : '99+'}}</view>
  49. </view>
  50. <view class="order-item-text">待发货</view>
  51. </view>
  52. <view class="order-item" @click="orderClick(4)">
  53. <view class="iconfont icondaishouhuo order-item-icon">
  54. <view v-if="num.unReceive" class="order-item-icon-num">{{num.unReceive < 99 ? num.unReceive : '99+'}}</view>
  55. </view>
  56. <view class="order-item-text">待收货</view>
  57. </view>
  58. <view class="order-item" @click="orderClick(5)">
  59. <view class="iconfont icondaipingjia order-item-icon">
  60. <view v-if="num.unComment" class="order-item-icon-num">{{num.unComment < 99 ? num.unComment : '99+'}}</view>
  61. </view>
  62. <view class="order-item-text">待评价</view>
  63. </view>
  64. </view>
  65. <view class="item-btn mt20" @click="addressClick()">
  66. <view class="iconfont icondizhiguanli item-btn-icon"></view>
  67. <view class="item-btn-text">收货地址</view>
  68. <view class="iconfont iconfangxiang"></view>
  69. </view>
  70. <view class="line-box">
  71. <view class="split-line"></view>
  72. </view>
  73. <view class="item-btn" @click="aboutUsClick()">
  74. <view class="iconfont iconguanyu item-btn-icon"></view>
  75. <view class="item-btn-text">关于我们</view>
  76. <view class="iconfont iconfangxiang"></view>
  77. </view>
  78. <view class="line-box" v-if="userData.userName">
  79. <view class="split-line"></view>
  80. </view>
  81. <view class="item-btn" @click="loginOut()" v-if="userData.userName">
  82. <view class="iconfont iconguanyu item-btn-icon"></view>
  83. <view class="item-btn-text">退出登录</view>
  84. <view class="iconfont iconfangxiang"></view>
  85. </view>
  86. </view>
  87. <u-top-tips ref="uTips"></u-top-tips>
  88. </view>
  89. </template>
  90. <script>
  91. const NET = require('@/utils/request')
  92. const API = require('@/config/api')
  93. export default {
  94. data() {
  95. return {
  96. integral: '',
  97. userData: {
  98. userId: '',
  99. userName: '',
  100. headImage: '',
  101. },
  102. mainInfo: {
  103. flag: false,
  104. entrustNo: '',
  105. totalIntegral: '',
  106. memberCouponNo: '',
  107. },
  108. num: {
  109. unComment: 0, // 待评价
  110. unPay: 0, // 待付款
  111. unReceive: 0, // 待收货
  112. unSend: 0 // 待发货
  113. }
  114. }
  115. },
  116. onShow() {
  117. this.userData = uni.getStorageSync("userData")
  118. this.getBaseData()
  119. this.getNum()
  120. },
  121. onPullDownRefresh() {
  122. this.getBaseData()
  123. setTimeout(() => {
  124. uni.stopPullDownRefresh();
  125. }, 500)
  126. },
  127. methods: {
  128. // 注销
  129. loginOut() {
  130. try {
  131. uni.clearStorageSync();
  132. uni.reLaunch({
  133. url: '/pages/index/login'
  134. });
  135. } catch (e) {
  136. console.log(e, '退出登录')
  137. }
  138. },
  139. gologin() {
  140. uni.reLaunch({
  141. url: '/pages/index/login'
  142. });
  143. },
  144. // 获取全部数据
  145. getBaseData() {
  146. NET.request(API.getMainInfo, {}, 'GET').then(res => {
  147. this.mainInfo = res.data
  148. }).catch(error => {
  149. this.$refs.uTips.show({
  150. title: '获取个人信息失败',
  151. type: 'warning',
  152. })
  153. })
  154. },
  155. // 获取订单数量
  156. getNum() {
  157. NET.request(API.getOrderNum, {}, 'GET').then(res => {
  158. if (res.isSuccess) {
  159. this.num = res.data
  160. } else {
  161. this.$refs.uTips.show({
  162. title: res.msg,
  163. type: 'warning',
  164. })
  165. }
  166. }).catch(error => {
  167. this.$refs.uTips.show({
  168. title: '获取个人信息失败',
  169. type: 'warning',
  170. })
  171. })
  172. },
  173. // 我的种植
  174. entrustClick() {
  175. uni.navigateTo({
  176. url: '/pagesMain/plantList'
  177. });
  178. },
  179. // 我的积分
  180. integralClick() {
  181. uni.navigateTo({
  182. url: '/pagesMain/integralList'
  183. });
  184. },
  185. // 我的优惠券
  186. couponClick() {
  187. uni.navigateTo({
  188. url: '/pagesMain/couponList'
  189. });
  190. },
  191. // 地址管理
  192. addressClick() {
  193. uni.navigateTo({
  194. url: '/pagesMain/addressList?type=1'
  195. });
  196. },
  197. // 我的订单
  198. orderClick(type) {
  199. uni.navigateTo({
  200. url: '/pagesMain/orderList?type=' + type
  201. });
  202. },
  203. // 关于我们
  204. aboutUsClick() {
  205. uni.navigateTo({
  206. url: '/pagesMain/aboutUs'
  207. });
  208. },
  209. }
  210. }
  211. </script>
  212. <style lang='scss'>
  213. page {
  214. width: 100%;
  215. height: 100%;
  216. }
  217. .content {
  218. width: 100%;
  219. height: 100%;
  220. background-color: #F3F3F3;
  221. .main-bg {
  222. width: 100%;
  223. height: 195px;
  224. position: relative;
  225. background-size: 100% 195px;
  226. background-position: center top;
  227. background-repeat: no-repeat;
  228. background-image: url(@/static/images/userbackground.png)
  229. }
  230. .page-content {
  231. width: 100%;
  232. height: 100%;
  233. display: flex;
  234. flex-direction: column;
  235. z-index: 10;
  236. margin-top: -200px;
  237. position: relative;
  238. .user-info-box {
  239. width: 100%;
  240. box-sizing: border-box;
  241. padding: 30upx;
  242. display: flex;
  243. flex-direction: row;
  244. align-items: center;
  245. .user-image {
  246. width: 130upx;
  247. height: 130upx;
  248. }
  249. .user-info {
  250. flex: 1;
  251. display: flex;
  252. flex-direction: column;
  253. padding-left: 20upx;
  254. box-sizing: border-box;
  255. z-index: 10;
  256. .user-logoin-title {
  257. font-size: 36upx;
  258. font-weight: 500;
  259. color: rgba(255, 255, 255, 1);
  260. }
  261. .user-level {
  262. width: 70px;
  263. height: 20px;
  264. background: #FFFFFF;
  265. color: #FF850C;
  266. display: flex;
  267. align-items: center;
  268. justify-content: center;
  269. font-size: 12px;
  270. }
  271. .user-logoin-lable {
  272. font-size: 24upx;
  273. font-weight: 400;
  274. color: rgba(255, 255, 255, 1);
  275. margin-top: 20upx;
  276. }
  277. }
  278. .user-info-right {
  279. width: 30upx;
  280. height: 30upx;
  281. }
  282. }
  283. .user-activity {
  284. display: flex;
  285. text-align: center;
  286. align-items: center;
  287. justify-content: center;
  288. padding: 0 15px 15px 15px;
  289. color: #FFFFFF;
  290. }
  291. .order-box {
  292. width: 690upx;
  293. height: 170upx;
  294. background: rgba(255, 255, 255, 1);
  295. box-shadow: 0px 0px 10upx 0px rgba(51, 51, 51, 0.1);
  296. border-radius: 10upx;
  297. display: flex;
  298. flex-direction: row;
  299. align-items: center;
  300. margin-left: 30upx;
  301. z-index: 10;
  302. .order-line {
  303. width: 12upx;
  304. height: 106upx;
  305. }
  306. .order-item {
  307. flex: 1;
  308. display: flex;
  309. flex-direction: column;
  310. align-items: center;
  311. justify-content: center;
  312. .order-item-icon {
  313. color: #52A63A;
  314. font-size: 30px;
  315. display: flex;
  316. position: relative;
  317. .order-item-icon-num {
  318. background: #ffffff;
  319. width: 22px;
  320. height: 20px;
  321. font-size: 12px;
  322. border-radius: 50%;
  323. color: #52A63A;
  324. text-align: center;
  325. position: absolute;
  326. left: 20px;
  327. border: 1px solid #52A63A;
  328. line-height: 20px;
  329. }
  330. }
  331. .order-item-text {
  332. font-size: 28upx;
  333. margin-top: 10upx;
  334. font-weight: 500;
  335. }
  336. }
  337. }
  338. .item-btn {
  339. width: 100%;
  340. height: 100upx;
  341. display: flex;
  342. flex-direction: row;
  343. align-items: center;
  344. box-sizing: border-box;
  345. background-color: #fff;
  346. padding: 0 30upx;
  347. .item-btn-icon {
  348. color: #52A63A;
  349. font-size: 20px;
  350. /* width: 48upx;
  351. height: 48upx; */
  352. }
  353. .item-btn-text {
  354. font-size: 28upx;
  355. margin-left: 20upx;
  356. font-weight: 500;
  357. flex: 1;
  358. color: rgba(102, 102, 102, 1);
  359. }
  360. }
  361. .line-box {
  362. height: 5px;
  363. display: flex;
  364. justify-content: center;
  365. align-items: center;
  366. background: #FFFFFF;
  367. .split-line {
  368. width: 100%;
  369. height: 1px;
  370. background: #EEEEEE;
  371. }
  372. }
  373. .mt20 {
  374. margin-top: 20upx;
  375. }
  376. .mb5 {
  377. margin-bottom: 5px;
  378. }
  379. .mr5 {
  380. margin-right: 5px;
  381. }
  382. .mr20 {
  383. margin-right: 20px;
  384. }
  385. .font18 {
  386. font-size: 18px;
  387. }
  388. .font10 {
  389. font-size: 10px;
  390. }
  391. }
  392. }
  393. </style>