index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399
  1. <template>
  2. <view class="container">
  3. <!-- 机构信息区域 -->
  4. <template v-if="isRequest">
  5. <view class="ws-header">
  6. <!-- 用户信息 -->
  7. <view class="user-info">
  8. <image
  9. class="user_default"
  10. v-if="!hasLogin && isRequest"
  11. :src="StaticUrl + 'icon-default-avatar.png'"
  12. mode="widthFix"
  13. ></image>
  14. <image class="user_default" v-else :src="UserInfo.headImgUrl" mode="widthFix"></image>
  15. <view class="user-login" v-if="!hasLogin && isRequest" @click="navigator('/pages/login/login')"
  16. >登录</view
  17. >
  18. <view class="user-text" v-else>
  19. {{ UserInfo.userIdentity == 1 ? UserInfo.nickName : UserInfo.name }}
  20. </view>
  21. </view>
  22. <!-- 背景图 -->
  23. <image class="user-bg" :src="StaticUrl + 'icon-user-bg@2x.png'" mode="widthFix"></image>
  24. </view>
  25. <!-- 机构信息END -->
  26. <!-- 订单状态区域 -->
  27. <view class="order-wrap">
  28. <view class="more">
  29. <text class="title">我的订单</text>
  30. <view @click="OrderNavigator(0)">
  31. <text class="more-right">全部订单</text> <text class="iconfont icon-chakangengduo"></text>
  32. </view>
  33. </view>
  34. <view class="line"></view>
  35. <!-- 菜单选项 -->
  36. <view class="order-nav">
  37. <view class="order-nav-item" @click="OrderNavigator(1)">
  38. <image :src="StaticUrl + 'icon-order-1@2x.png'" mode="widthFix"></image> <text>待付款</text>
  39. <view class="tui-badge tui-badge-box" v-if="hasLogin && paymentCount > 0">
  40. <tui-badge :scaleRatio="0.8" type="danger">{{ paymentCount | countNum }}</tui-badge>
  41. </view>
  42. </view>
  43. <view class="order-nav-item" @click="OrderNavigator(2)">
  44. <image :src="StaticUrl + 'icon-order-2@2x.png'" mode="widthFix"></image> <text>待发货</text>
  45. <view class="tui-badge tui-badge-box" v-if="hasLogin && waitShipmentsCount > 0">
  46. <tui-badge :scaleRatio="0.8" type="danger">{{ waitShipmentsCount | countNum }}</tui-badge>
  47. </view>
  48. </view>
  49. <view class="order-nav-item" @click="OrderNavigator(3)">
  50. <image :src="StaticUrl + 'icon-order-3@2x.png'" mode="widthFix"></image> <text>已发货</text>
  51. <view class="tui-badge tui-badge-box" v-if="hasLogin && shipmentsCount > 0">
  52. <tui-badge :scaleRatio="0.8" type="danger">{{ shipmentsCount | countNum }}</tui-badge>
  53. </view>
  54. </view>
  55. <view class="order-nav-item" @click="OrderNavigator(3)">
  56. <image :src="StaticUrl + 'icon-order-4@2x.png'" mode="widthFix"></image> <text>退货/款</text>
  57. <view class="tui-badge tui-badge-box" v-if="hasLogin && salesReturnCount > 0">
  58. <tui-badge :scaleRatio="0.8" type="danger">{{ salesReturnCount | countNum }}</tui-badge>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 订单状态区域END -->
  64. <!-- 菜单导航区域 -->
  65. <view class="place-menu-conten clearfix">
  66. <view
  67. class="place-menu-cell"
  68. @click="navigator('/pages/user/activity/activity-list')"
  69. v-if="UserInfo.userIdentity == 2"
  70. >
  71. <view class="place-left">
  72. <image class="place-menu-icon" :src="StaticUrl + 'icon-user-h@2x.png'" mode=""></image>
  73. <text class="place-menu-title">活动专区</text>
  74. </view>
  75. <text class="iconfont icon-chakangengduo"></text>
  76. </view>
  77. <view class="place-menu-cell" @click="navigator('/pages/user/address/address')">
  78. <view class="place-left">
  79. <image class="place-menu-icon" :src="StaticUrl + 'icon-user-d@2x.png'" mode=""></image>
  80. <text class="place-menu-title">收货地址</text>
  81. </view>
  82. <text class="iconfont icon-chakangengduo"></text>
  83. </view>
  84. <button class="place-menu-cell last" open-type="contact" @bindcontact="handleContact">
  85. <view class="place-left">
  86. <image class="place-menu-icon" :src="StaticUrl + 'icon-user-c@2x.png'" mode=""></image>
  87. <text class="place-menu-title">在线客服</text>
  88. </view>
  89. <text class="iconfont icon-chakangengduo"></text>
  90. </button>
  91. </view>
  92. <!-- 菜单导航区域END -->
  93. <!-- 底部 -->
  94. <view class="user-support" :class="UserInfo.userIdentity == 2 ? 'top' : ''">
  95. <image class="user-support-image" :src="StaticUrl + 'icon-logo@1x.png'" mode=""></image>
  96. <view class="user-support-text">采美365网提供商品技术服务</view>
  97. </view>
  98. </template>
  99. </view>
  100. </template>
  101. <script>
  102. import nutBadge from '@/components/thorui/tui-badge/tui-badge.vue'
  103. import { mapGetters, mapMutations } from 'vuex'
  104. import authorize from '@/common/authorize.js'
  105. import wxLogin from '@/services/wxLogin.js'
  106. export default {
  107. components: {
  108. nutBadge
  109. },
  110. data() {
  111. return {
  112. StaticUrl: this.$Static,
  113. CustomBar: this.CustomBar, // 顶部导航栏高度
  114. UserInfo: {}, //用户信息
  115. isRequest: true,
  116. paymentCount: 0, //待付款角标
  117. waitShipmentsCount: 0, //待收货角标
  118. shipmentsCount: 0, //已发货角标
  119. salesReturnCount: 0, //退货/款角标
  120. userId: 0
  121. }
  122. },
  123. onLoad() {},
  124. computed: {
  125. ...mapGetters(['hasLogin', 'userInfo', 'isWxAuthorize'])
  126. },
  127. filters: {
  128. countNum(value) {
  129. return value > 99 ? '99+' : value
  130. }
  131. },
  132. onPullDownRefresh() {
  133. //下拉刷新
  134. if (this.hasLogin) {
  135. this.GetUserInfo()
  136. setTimeout(() => {
  137. uni.stopPullDownRefresh()
  138. }, 2000)
  139. } else {
  140. uni.stopPullDownRefresh()
  141. }
  142. },
  143. methods: {
  144. ...mapMutations('app', ['login', 'logout']),
  145. GetUserInfo() {
  146. this.UserInfo = uni.getStorageSync('userInfo')
  147. this.$api.getStorage().then(resolve => {
  148. this.userId = resolve.userId ? resolve.userId : ''
  149. this.GetUserInfoPersonal()
  150. })
  151. },
  152. //初始化个人中心数据
  153. GetUserInfoPersonal() {
  154. this.UserService.GetUserOrderTotal({
  155. userId: this.userId
  156. })
  157. .then(response => {
  158. const data = response.data
  159. this.paymentCount = data.paymentCount //待付款
  160. this.waitShipmentsCount = data.waitShipmentsCount //待收货
  161. this.shipmentsCount = data.shipmentsCount //已发货
  162. this.salesReturnCount = data.salesReturnCount //退货/款
  163. })
  164. .catch(error => {
  165. this.$util.msg(error.msg, 2000)
  166. })
  167. },
  168. handleContact(e) {
  169. //客服
  170. console.log(e.detail.path)
  171. console.log(e.detail.query)
  172. },
  173. OrderNavigator(state) {
  174. // 栏目跳转
  175. if (this.hasLogin) {
  176. if (this.UserInfo.userIdentity == 2) {
  177. this.$api.navigateTo(`/pages/user/order/order-list-retail?state=${state}`)
  178. } else {
  179. this.$api.navigateTo(`/pages/user/order/order-list?state=${state}`)
  180. }
  181. } else {
  182. this.$api.navigateTo('/pages/login/login')
  183. }
  184. },
  185. navigator(url) {
  186. if (this.hasLogin) {
  187. this.$api.navigateTo(url)
  188. } else {
  189. this.$api.navigateTo('/pages/login/login')
  190. }
  191. }
  192. },
  193. onShow() {
  194. if (this.hasLogin) {
  195. this.GetUserInfo()
  196. }
  197. }
  198. }
  199. </script>
  200. <style lang="scss">
  201. @import '@/uni.scss';
  202. .container {
  203. box-sizing: border-box;
  204. background: #f7f7f7;
  205. }
  206. // 用户登录信息区域
  207. .ws-title {
  208. width: 100%;
  209. position: fixed;
  210. top: 0;
  211. left: 0;
  212. font-size: 34rpx;
  213. text-align: center;
  214. }
  215. .ws-header {
  216. position: relative;
  217. height: 280rpx;
  218. .user-info {
  219. position: absolute;
  220. z-index: 10;
  221. width: 750rpx;
  222. height: 280rpx;
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. justify-content: center;
  227. .user_default {
  228. display: block;
  229. width: 120rpx;
  230. height: 120rpx;
  231. border-radius: 50%;
  232. }
  233. }
  234. // 登录按钮
  235. .user-login {
  236. width: 184rpx;
  237. height: 56rpx;
  238. margin-top: 25rpx;
  239. border-radius: 28rpx;
  240. background: #ffffff;
  241. line-height: 56rpx;
  242. text-align: center;
  243. color: $color-system;
  244. font-size: $font-size-28;
  245. }
  246. // 公司名
  247. .user-text {
  248. width: 446rpx;
  249. margin-top: 25rpx;
  250. color: #fff;
  251. font-size: 28rpx;
  252. line-height: 40rpx;
  253. text-align: center;
  254. white-space: nowrap;
  255. overflow: hidden;
  256. text-overflow: ellipsis;
  257. }
  258. .user-bg {
  259. width: 100%;
  260. }
  261. }
  262. .more {
  263. width: 750rpx;
  264. display: flex;
  265. justify-content: space-between;
  266. align-items: center;
  267. padding: 23rpx 25rpx;
  268. box-sizing: border-box;
  269. background: #fff;
  270. .more-right {
  271. font-size: 26rpx;
  272. line-height: 37rpx;
  273. margin-right: 10rpx;
  274. }
  275. .title {
  276. font-size: 32rpx;
  277. line-height: 45rpx;
  278. color: #333333;
  279. }
  280. .iconfont {
  281. font-size: 20rpx;
  282. vertical-align: middle;
  283. }
  284. }
  285. .order-wrap {
  286. background: #fff;
  287. .line {
  288. width: 702rpx;
  289. height: 1px;
  290. margin: 0 auto;
  291. background: #f0f0f0;
  292. }
  293. .order-nav {
  294. display: flex;
  295. justify-content: space-evenly;
  296. align-items: center;
  297. padding: 40rpx 0;
  298. .order-nav-item {
  299. position: relative;
  300. display: flex;
  301. align-items: center;
  302. flex-direction: column;
  303. image {
  304. width: 64rpx;
  305. height: 64rpx;
  306. }
  307. text {
  308. font-size: 26rpx;
  309. line-height: 37rpx;
  310. margin-top: 8rpx;
  311. }
  312. .tui-badge {
  313. position: absolute;
  314. top: -15rpx;
  315. right: -25rpx;
  316. z-index: 999;
  317. }
  318. }
  319. }
  320. }
  321. .place-menu-conten {
  322. margin-top: 20rpx;
  323. width: 100%;
  324. height: auto;
  325. box-sizing: border-box;
  326. padding: 0 24rpx;
  327. background-color: #ffffff;
  328. .place-menu-cell {
  329. width: 100%;
  330. height: 110rpx;
  331. box-sizing: border-box;
  332. padding: 36rpx 0;
  333. text-align: left;
  334. float: left;
  335. border-bottom: 1px solid #e1e1e1;
  336. position: relative;
  337. &.last {
  338. border-bottom: none;
  339. }
  340. .place-left {
  341. width: 600rpx;
  342. height: 100%;
  343. .place-menu-icon {
  344. width: 36rpx;
  345. height: 36rpx;
  346. display: block;
  347. float: left;
  348. }
  349. .place-menu-title {
  350. width: 540rpx;
  351. margin-left: 16rpx;
  352. float: left;
  353. height: 36rpx;
  354. line-height: 36rpx;
  355. font-size: $font-size-28;
  356. color: #333333;
  357. }
  358. }
  359. .iconfont {
  360. width: 36rpx;
  361. height: 36rpx;
  362. display: block;
  363. line-height: 36rpx;
  364. text-align: center;
  365. font-size: $font-size-30;
  366. color: #cccccc;
  367. position: absolute;
  368. right: 0;
  369. top: 36rpx;
  370. }
  371. }
  372. }
  373. .user-support {
  374. width: 100%;
  375. float: left;
  376. margin-top: 340rpx;
  377. display: flex;
  378. flex-direction: column;
  379. align-items: center;
  380. justify-content: center;
  381. &.top {
  382. margin-top: 240rpx;
  383. }
  384. .user-support-image {
  385. width: 54rpx;
  386. height: 46rpx;
  387. display: block;
  388. margin-bottom: 5rpx;
  389. }
  390. .user-support-text {
  391. font-size: 20rpx;
  392. line-height: 30rpx;
  393. color: #cccccc;
  394. }
  395. }
  396. </style>