index.vue 9.8 KB

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