index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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 src="@/static/ws/default_avatar.png" mode="widthFix"></image>
  9. <view
  10. class="ws-login"
  11. @click="navigator('/pages/login/login')"
  12. v-if="!hasLogin && isRequest"
  13. >
  14. 请登录
  15. </view>
  16. <view class="user-text" v-else> {{ organizeName }} </view>
  17. </view>
  18. <!-- 背景图 -->
  19. <image class="user-bg" src="@/static/ws/user_bg.png" mode="widthFix"></image>
  20. </view>
  21. <!-- 机构信息END -->
  22. <!-- 订单状态区域 -->
  23. <view class="order-wrap">
  24. <view class="more">
  25. <text class="title">我的订单</text>
  26. <view @click="navigator('/pages/user/order/order-list?state=0')">
  27. <text class="more-right">全部订单</text>
  28. <text class="iconfont icon-chakangengduo"></text>
  29. </view>
  30. </view>
  31. <view class="line"></view>
  32. <!-- 菜单选项 -->
  33. <view class="order-nav">
  34. <view
  35. class="order-nav-item"
  36. @click="navigator('/pages/user/order/order-list?state=1')"
  37. >
  38. <image src="@/static/ws/dh_dfk_02.png" mode="widthFix"></image>
  39. <text>待付款</text>
  40. </view>
  41. <view
  42. class="order-nav-item"
  43. @click="navigator('/pages/user/order/order-list?state=2')"
  44. >
  45. <image src="@/static/ws/dh_dfh_03.png" mode="widthFix"></image>
  46. <text>待发货</text>
  47. </view>
  48. <view
  49. class="order-nav-item"
  50. @click="navigator('/pages/user/order/order-list?state=3')"
  51. >
  52. <image src="@/static/ws/dh_yfh_04.png" mode="widthFix"></image>
  53. <text>已发货</text>
  54. </view>
  55. <view
  56. class="order-nav-item"
  57. @click="navigator('/pages/user/order/order-list?state=4')"
  58. >
  59. <image src="@/static/ws/dh_tk_05.png" mode="widthFix"></image>
  60. <text>退货/款</text>
  61. </view>
  62. </view>
  63. </view>
  64. <!-- 订单状态区域END -->
  65. <!-- 帮机构下单 -->
  66. <view
  67. class="place-order"
  68. @click="navigator(`/pages/user/club/club-list?id=${organizeId}`)"
  69. >
  70. <view class="place-left">
  71. <text class="iconfont icon-bangjigouxiadan"></text>
  72. <text class="title">帮机构下单</text>
  73. </view>
  74. <text class="iconfont icon-chakangengduo"></text>
  75. </view>
  76. <!-- 帮机构下单END -->
  77. <!-- 客服 -->
  78. <button class="ws-service" open-type="contact" @bindcontact="handleContact">
  79. <text class="iconfont icon-zaixiankefu"></text> 在线客服
  80. </button>
  81. </template>
  82. </view>
  83. </template>
  84. <script>
  85. import nutBadge from '@/components/thorui/tui-badge/tui-badge.vue'
  86. import { mapState, mapMutations } from 'vuex'
  87. import authorize from '@/common/config/authorize.js'
  88. import wxLogin from '@/common/config/wxLogin.js'
  89. export default {
  90. components: {
  91. nutBadge
  92. },
  93. data() {
  94. return {
  95. organizeName: '', //采购员组织名称
  96. isRequest: false,
  97. paymentCount: 0, //待付款角标
  98. waitShipmentsCount: 0, //待收货角标
  99. shipmentsCount: 0, //已发货角标
  100. salesReturnCount: '', //退货/款角标
  101. organizeId: '',
  102. refresh: false
  103. }
  104. },
  105. onLoad() {
  106. // 获取用户是否授权
  107. //0:为取消授权 1:为已授权 2:为未操作
  108. authorize.getSetting().then(res => {
  109. if (res == 1) {
  110. console.log('用户已授权')
  111. this.GetWxAuthorize()
  112. }else{
  113. this.isRequest = true
  114. }
  115. })
  116. },
  117. computed: {
  118. ...mapState(['hasLogin', 'userInfo'])
  119. },
  120. methods: {
  121. ...mapMutations(['login', 'logout']),
  122. // 授权登录验证
  123. async GetWxAuthorize() {
  124. // 获取微信code
  125. const wechatCode = await authorize.getCode('weixin')
  126. this.UserService.userInfoLogin({ code: wechatCode })
  127. .then(res => {
  128. // 登录成功 将信息保存在userInfo中 保存在本地和store
  129. this.login(res.data)
  130. this.organizeId = res.data.organizeId
  131. // 初始化个人中心
  132. this.getUserInfoPersonal(this.organizeId)
  133. this.refresh = true
  134. this.isRequest = true //个人中心初始化成功后才显示页面
  135. })
  136. .catch(err => {
  137. // 缓存游客openid
  138. uni.setStorageSync('openid', err.data.openid)
  139. this.logout()
  140. this.refresh = true
  141. this.isRequest = true
  142. })
  143. },
  144. //初始化个人中心数据
  145. getUserInfoPersonal(organizeId) {
  146. this.UserService.userInfoPersonal({ organizeId: organizeId })
  147. .then(response => {
  148. this.organizeName = response.data.organizeName //采购员组织名称
  149. this.paymentCount = this.showBadge(response.data.paymentCount) //待付款
  150. this.waitShipmentsCount = this.showBadge(response.data.waitShipmentsCount) //待收货
  151. this.shipmentsCount = this.showBadge(response.data.shipmentsCount) //已发货
  152. this.salesReturnCount = this.showBadge(response.data.salesReturnCount) //退货/款
  153. })
  154. .catch(error => {
  155. this.$util.msg(error.msg, 2000)
  156. })
  157. },
  158. // 客服
  159. handleContact(e) {
  160. console.log(e.detail.path)
  161. console.log(e.detail.query)
  162. },
  163. // 栏目跳转
  164. navigator(url) {
  165. authorize.getSetting().then(res => {
  166. // console.log('是否已授权',res);
  167. //0:为取消授权 1:为已授权 2:为未操作
  168. if (res == 1) {
  169. if (this.hasLogin) {
  170. // 已登录
  171. this.$api.navigateTo(url)
  172. } else {
  173. // 未登录
  174. this.$api.navigateTo(`/pages/login/login`)
  175. }
  176. } else {
  177. this.$api.navigateTo(`/pages/authorization/authorization`)
  178. }
  179. })
  180. },
  181. //下拉刷新
  182. onPullDownRefresh() {
  183. if (this.hasLogin) {
  184. this.GetWxAuthorize()
  185. if (this.refresh) {
  186. uni.stopPullDownRefresh()
  187. }
  188. } else {
  189. uni.stopPullDownRefresh()
  190. }
  191. }
  192. }
  193. }
  194. </script>
  195. <style lang="scss">
  196. @import '@/uni.scss';
  197. .container {
  198. background: #f7f7f7;
  199. }
  200. // 用户登录信息区域
  201. .ws-header {
  202. position: relative;
  203. height: 280rpx;
  204. .user-info {
  205. position: absolute;
  206. z-index: 10;
  207. width: 750rpx;
  208. height: 280rpx;
  209. display: flex;
  210. flex-direction: column;
  211. align-items: center;
  212. justify-content: center;
  213. image {
  214. display: block;
  215. width: 120rpx;
  216. height: 120rpx;
  217. border-radius: 50%;
  218. }
  219. }
  220. // 登录按钮
  221. .ws-login {
  222. width: 184rpx;
  223. height: 56rpx;
  224. margin-top: 25rpx;
  225. border-radius: 28rpx;
  226. background: linear-gradient(to right, #fccd90, #b6762f);
  227. line-height: 56rpx;
  228. text-align: center;
  229. color: #ffffff;
  230. font-size: 28rpx;
  231. }
  232. // 公司名
  233. .user-text {
  234. width: 446rpx;
  235. margin-top: 25rpx;
  236. color: #fff;
  237. font-size: 28rpx;
  238. line-height: 40rpx;
  239. text-align: center;
  240. white-space: nowrap;
  241. overflow: hidden;
  242. text-overflow: ellipsis;
  243. }
  244. .user-bg {
  245. width: 100%;
  246. }
  247. }
  248. .more {
  249. width: 750rpx;
  250. display: flex;
  251. justify-content: space-between;
  252. align-items: center;
  253. padding: 23rpx 25rpx;
  254. box-sizing: border-box;
  255. background: #fff;
  256. .more-right {
  257. font-size: 26rpx;
  258. line-height: 37rpx;
  259. margin-right: 10rpx;
  260. }
  261. .title {
  262. font-size: 32rpx;
  263. line-height: 45rpx;
  264. color: #333333;
  265. }
  266. .iconfont {
  267. font-size: 20rpx;
  268. vertical-align: middle;
  269. }
  270. }
  271. .order-wrap {
  272. background: #fff;
  273. .line {
  274. width: 702rpx;
  275. height: 1px;
  276. margin: 0 auto;
  277. background: #f0f0f0;
  278. }
  279. .order-nav {
  280. display: flex;
  281. justify-content: space-evenly;
  282. align-items: center;
  283. padding: 40rpx 0;
  284. .order-nav-item {
  285. display: flex;
  286. align-items: center;
  287. flex-direction: column;
  288. image {
  289. width: 56rpx;
  290. height: 56rpx;
  291. }
  292. text {
  293. font-size: 26rpx;
  294. line-height: 37rpx;
  295. margin-top: 8rpx;
  296. }
  297. }
  298. }
  299. }
  300. .place-order {
  301. width: 750rpx;
  302. display: flex;
  303. justify-content: space-between;
  304. align-items: center;
  305. padding: 23rpx 25rpx;
  306. box-sizing: border-box;
  307. background: #fff;
  308. margin-top: 20rpx;
  309. .place-left {
  310. .title {
  311. font-size: 28rpx;
  312. line-height: 40rpx;
  313. margin-left: 10rpx;
  314. }
  315. .iconfont {
  316. font-size: 36rpx;
  317. vertical-align: middle;
  318. }
  319. }
  320. .iconfont {
  321. font-size: 20rpx;
  322. }
  323. }
  324. .ws-service {
  325. width: 160rpx;
  326. height: 48rpx;
  327. margin: 40rpx auto 0;
  328. display: flex;
  329. justify-content: center;
  330. align-items: center;
  331. font-size: 22rpx;
  332. background: linear-gradient(to right, #fccd90, #b6762f);
  333. color: #fff;
  334. border-radius: 24rpx;
  335. .iconfont {
  336. font-size: 30rpx;
  337. margin-right: 6rpx;
  338. }
  339. }
  340. .badge {
  341. background-color: #ff0000;
  342. }
  343. </style>