index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view class="container" :style="{ paddingTop: CustomBar + 'px' }">
  3. <cm-custom :navbar-data="nvabarData"></cm-custom>
  4. <!-- 机构信息区域 -->
  5. <template v-if="isRequest">
  6. <!-- <view class="ws-title" :style="{lineHeight :CustomBar + 'px' }">维沙采购商城</view> -->
  7. <view class="ws-header">
  8. <!-- 用户信息 -->
  9. <view class="user-info">
  10. <image src="@/static/ws/default_avatar.png" mode="widthFix"></image>
  11. <view
  12. class="ws-login"
  13. @click="navigator('/pages/login/login')"
  14. v-if="!hasLogin && isRequest"
  15. >
  16. 邀请码登录
  17. </view>
  18. <view class="user-text" v-else> {{ organizeName }} </view>
  19. </view>
  20. <!-- 背景图 -->
  21. <image class="user-bg" src="@/static/ws/user_bg.png" mode="widthFix"></image>
  22. </view>
  23. <!-- 机构信息END -->
  24. <!-- 订单状态区域 -->
  25. <view class="order-wrap">
  26. <view class="more">
  27. <text class="title">我的订单</text>
  28. <view @click="navigator('/pages/user/order/order-list?state=0')">
  29. <text class="more-right">全部订单</text>
  30. <text class="iconfont icon-chakangengduo"></text>
  31. </view>
  32. </view>
  33. <view class="line"></view>
  34. <!-- 菜单选项 -->
  35. <view class="order-nav">
  36. <view
  37. class="order-nav-item"
  38. @click="navigator('/pages/user/order/order-list?state=1')"
  39. >
  40. <image src="@/static/ws/dh_dfk_02.png" mode="widthFix"></image>
  41. <text>待付款</text>
  42. <view class="tui-badge tui-badge-box" v-if="paymentCount > 0">
  43. <tui-badge :scaleRatio="0.8" type="danger">{{
  44. paymentCount | countNum
  45. }}</tui-badge>
  46. </view>
  47. </view>
  48. <view
  49. class="order-nav-item"
  50. @click="navigator('/pages/user/order/order-list?state=2')"
  51. >
  52. <image src="@/static/ws/dh_dfh_03.png" mode="widthFix"></image>
  53. <text>待发货</text>
  54. <view class="tui-badge tui-badge-box" v-if="waitShipmentsCount > 0">
  55. <tui-badge :scaleRatio="0.8" type="danger">{{
  56. waitShipmentsCount | countNum
  57. }}</tui-badge>
  58. </view>
  59. </view>
  60. <view
  61. class="order-nav-item"
  62. @click="navigator('/pages/user/order/order-list?state=3')"
  63. >
  64. <image src="@/static/ws/dh_yfh_04.png" mode="widthFix"></image>
  65. <text>已发货</text>
  66. <view class="tui-badge tui-badge-box" v-if="shipmentsCount > 0">
  67. <tui-badge :scaleRatio="0.8" type="danger">{{
  68. shipmentsCount | countNum
  69. }}</tui-badge>
  70. </view>
  71. </view>
  72. <view
  73. class="order-nav-item"
  74. @click="navigator('/pages/user/order/order-list?state=4')"
  75. >
  76. <image src="@/static/ws/dh_tk_05.png" mode="widthFix"></image>
  77. <text>退货/款</text>
  78. <view class="tui-badge tui-badge-box" v-if="salesReturnCount > 0">
  79. <tui-badge :scaleRatio="0.8" type="danger">{{
  80. salesReturnCount | countNum
  81. }}</tui-badge>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. <!-- 订单状态区域END -->
  87. <!-- 帮机构下单 -->
  88. <view
  89. class="place-order"
  90. @click="navigator(`/pages/user/club/club-list?id=${organizeId}`)"
  91. >
  92. <view class="place-left">
  93. <text class="iconfont icon-bangjigouxiadan"></text>
  94. <text class="title">帮机构下单</text>
  95. </view>
  96. <text class="iconfont icon-chakangengduo"></text>
  97. </view>
  98. <!-- 帮机构下单END -->
  99. <!-- 客服 -->
  100. <button class="ws-service" open-type="contact" @bindcontact="handleContact">
  101. <text class="iconfont icon-zaixiankefu"></text> 在线客服
  102. </button>
  103. </template>
  104. </view>
  105. </template>
  106. <script>
  107. import nutBadge from '@/components/thorui/tui-badge/tui-badge.vue'
  108. import { mapState, mapMutations } from 'vuex'
  109. import authorize from '@/common/config/authorize.js'
  110. import wxLogin from '@/common/config/wxLogin.js'
  111. export default {
  112. components: {
  113. nutBadge
  114. },
  115. data() {
  116. return {
  117. nvabarData: {
  118. //顶部自定义导航
  119. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  120. showSearch: 0,
  121. title: '维沙采购商城', // 导航栏 中间的标题
  122. haveBack: false,
  123. textLeft: this.$store.state.isIphone,
  124. textColor: '#333333',
  125. bgColor: '#ffffff'
  126. },
  127. CustomBar: this.CustomBar, // 顶部导航栏高度
  128. organizeName: '', //采购员组织名称
  129. isRequest: false,
  130. paymentCount: 0, //待付款角标
  131. waitShipmentsCount: 0, //待收货角标
  132. shipmentsCount: 0, //已发货角标
  133. salesReturnCount: 0, //退货/款角标
  134. organizeId: '',
  135. refresh: false
  136. }
  137. },
  138. onLoad() {
  139. // 获取用户是否授权
  140. //0:为取消授权 1:为已授权 2:为未操作
  141. // if(wx.getUserProfile){
  142. // this.GetWxAuthorize()
  143. // }else{
  144. // this.isRequest = true
  145. // }
  146. authorize
  147. .checkLogin()
  148. .then(res => {
  149. this.GetWxAuthorize()
  150. })
  151. .catch(err => {
  152. this.isRequest = true
  153. })
  154. // authorize.getSetting().then(res => {
  155. // if (res == 1) {
  156. // console.log('用户已授权')
  157. // this.GetWxAuthorize()
  158. // } else {
  159. // this.isRequest = true
  160. // }
  161. // })
  162. },
  163. computed: {
  164. ...mapState(['hasLogin', 'userInfo'])
  165. },
  166. filters: {
  167. countNum(value) {
  168. return value > 99 ? '99+' : value
  169. }
  170. },
  171. methods: {
  172. ...mapMutations(['login', 'logout']),
  173. // 授权登录验证
  174. async GetWxAuthorize() {
  175. // 获取微信code
  176. const wechatCode = await authorize.getCode('weixin')
  177. this.UserService.userInfoLogin({
  178. code: wechatCode
  179. })
  180. .then(res => {
  181. // 登录成功 将信息保存在userInfo中 保存在本地和store
  182. this.login(res.data)
  183. this.organizeId = res.data.organizeId
  184. this.getUserInfoPersonal(this.organizeId)
  185. this.refresh = true
  186. this.isRequest = true
  187. })
  188. .catch(err => {
  189. // 缓存游客openid
  190. uni.setStorageSync('openid', err.data.openid)
  191. this.logout()
  192. this.refresh = true
  193. this.isRequest = true
  194. })
  195. },
  196. //初始化个人中心数据
  197. getUserInfoPersonal(organizeId) {
  198. this.UserService.userInfoPersonal({ organizeId: organizeId })
  199. .then(response => {
  200. console.log(response)
  201. this.organizeName = response.data.organizeName //采购员组织名称
  202. this.paymentCount = response.data.paymentCount //待付款
  203. this.waitShipmentsCount = response.data.waitShipmentsCount //待收货
  204. this.shipmentsCount = response.data.shipmentsCount //已发货
  205. this.salesReturnCount = response.data.salesReturnCount //退货/款
  206. })
  207. .catch(error => {
  208. this.$util.msg(error.msg, 2000)
  209. })
  210. },
  211. // 客服
  212. handleContact(e) {
  213. console.log(e.detail.path)
  214. console.log(e.detail.query)
  215. },
  216. // 栏目跳转
  217. navigator(url) {
  218. const _that = this
  219. authorize
  220. .checkLogin()
  221. .then(res => {
  222. if (res === 1) {
  223. if (this.hasLogin) {
  224. // 已登录
  225. _that.$api.navigateTo(url)
  226. } else {
  227. // 未登录
  228. _that.$api.navigateTo(`/pages/login/login`)
  229. }
  230. }
  231. })
  232. .catch(err => {
  233. _that.$api.navigateTo(`/pages/authorization/authorization`)
  234. })
  235. // authorize.getSetting().then(res => {
  236. // console.log('是否已授权',res);
  237. // //0:为取消授权 1:为已授权 2:为未操作
  238. // if (res == 1) {
  239. // if (this.hasLogin) {
  240. // // 已登录
  241. // this.$api.navigateTo(url)
  242. // } else {
  243. // // 未登录
  244. // this.$api.navigateTo(`/pages/login/login`)
  245. // }
  246. // } else {
  247. // this.$api.navigateTo(`/pages/authorization/authorization`)
  248. // }
  249. // })
  250. },
  251. //下拉刷新
  252. onPullDownRefresh() {
  253. if (this.hasLogin) {
  254. this.GetWxAuthorize()
  255. if (this.refresh) {
  256. uni.stopPullDownRefresh()
  257. }
  258. } else {
  259. uni.stopPullDownRefresh()
  260. }
  261. },
  262. onShareAppMessage(res) {
  263. //分享转发
  264. this.isShareModal = false
  265. if (res.from === 'button') {
  266. // 来自页面内转发按钮
  267. }
  268. return {
  269. title: '维沙采购商城上线啦,快来采购吧~',
  270. path: `/pages/index/index`,
  271. imageUrl: 'https://static-b.caimei365.com/app/wisa/img/icon/icon-index.png'
  272. }
  273. }
  274. }
  275. }
  276. </script>
  277. <style lang="scss">
  278. @import '@/uni.scss';
  279. .container {
  280. box-sizing: border-box;
  281. background: #f7f7f7;
  282. }
  283. // 用户登录信息区域
  284. .ws-title {
  285. width: 100%;
  286. position: fixed;
  287. top: 0;
  288. left: 0;
  289. font-size: 34rpx;
  290. text-align: center;
  291. }
  292. .ws-header {
  293. position: relative;
  294. height: 280rpx;
  295. .user-info {
  296. position: absolute;
  297. z-index: 10;
  298. width: 750rpx;
  299. height: 280rpx;
  300. display: flex;
  301. flex-direction: column;
  302. align-items: center;
  303. justify-content: center;
  304. image {
  305. display: block;
  306. width: 120rpx;
  307. height: 120rpx;
  308. border-radius: 50%;
  309. }
  310. }
  311. // 登录按钮
  312. .ws-login {
  313. width: 184rpx;
  314. height: 56rpx;
  315. margin-top: 25rpx;
  316. border-radius: 28rpx;
  317. background: linear-gradient(to right, #fccd90, #b6762f);
  318. line-height: 56rpx;
  319. text-align: center;
  320. color: #ffffff;
  321. font-size: 28rpx;
  322. }
  323. // 公司名
  324. .user-text {
  325. width: 446rpx;
  326. margin-top: 25rpx;
  327. color: #fff;
  328. font-size: 28rpx;
  329. line-height: 40rpx;
  330. text-align: center;
  331. white-space: nowrap;
  332. overflow: hidden;
  333. text-overflow: ellipsis;
  334. }
  335. .user-bg {
  336. width: 100%;
  337. }
  338. }
  339. .more {
  340. width: 750rpx;
  341. display: flex;
  342. justify-content: space-between;
  343. align-items: center;
  344. padding: 23rpx 25rpx;
  345. box-sizing: border-box;
  346. background: #fff;
  347. .more-right {
  348. font-size: 26rpx;
  349. line-height: 37rpx;
  350. margin-right: 10rpx;
  351. }
  352. .title {
  353. font-size: 32rpx;
  354. line-height: 45rpx;
  355. color: #333333;
  356. }
  357. .iconfont {
  358. font-size: 20rpx;
  359. vertical-align: middle;
  360. }
  361. }
  362. .order-wrap {
  363. background: #fff;
  364. .line {
  365. width: 702rpx;
  366. height: 1px;
  367. margin: 0 auto;
  368. background: #f0f0f0;
  369. }
  370. .order-nav {
  371. display: flex;
  372. justify-content: space-evenly;
  373. align-items: center;
  374. padding: 40rpx 0;
  375. .order-nav-item {
  376. position: relative;
  377. display: flex;
  378. align-items: center;
  379. flex-direction: column;
  380. image {
  381. width: 56rpx;
  382. height: 56rpx;
  383. }
  384. text {
  385. font-size: 26rpx;
  386. line-height: 37rpx;
  387. margin-top: 8rpx;
  388. }
  389. .tui-badge {
  390. position: absolute;
  391. top: -15rpx;
  392. right: -20rpx;
  393. z-index: 999;
  394. }
  395. }
  396. }
  397. }
  398. .place-order {
  399. width: 750rpx;
  400. display: flex;
  401. justify-content: space-between;
  402. align-items: center;
  403. padding: 23rpx 25rpx;
  404. box-sizing: border-box;
  405. background: #fff;
  406. margin-top: 20rpx;
  407. .place-left {
  408. .title {
  409. font-size: 28rpx;
  410. line-height: 40rpx;
  411. margin-left: 10rpx;
  412. }
  413. .iconfont {
  414. font-size: 36rpx;
  415. vertical-align: middle;
  416. }
  417. }
  418. .iconfont {
  419. font-size: 20rpx;
  420. }
  421. }
  422. .ws-service {
  423. width: 160rpx;
  424. height: 48rpx;
  425. margin: 40rpx auto 0;
  426. display: flex;
  427. justify-content: center;
  428. align-items: center;
  429. font-size: 22rpx;
  430. background: linear-gradient(to right, #fccd90, #b6762f);
  431. color: #fff;
  432. border-radius: 24rpx;
  433. .iconfont {
  434. font-size: 30rpx;
  435. margin-right: 6rpx;
  436. }
  437. }
  438. </style>