index.vue 10 KB

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