index.vue 11 KB

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