index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. <template>
  2. <view class="container">
  3. <!-- 机构信息区域 -->
  4. <view class="ws-header">
  5. <!-- 用户信息 -->
  6. <view class="user-info">
  7. <image src="@/static/ws/default_avatar.png" mode="widthFix"></image>
  8. <view
  9. class="ws-login"
  10. @click="navigator('/pages/login/login?type=0')"
  11. v-if="!hasLogin"
  12. >
  13. 请登录
  14. </view>
  15. <view class="user-text" v-else> 瑞恺迪光电科技有限公司有限公司 </view>
  16. </view>
  17. <!-- 背景图 -->
  18. <image class="user-bg" src="@/static/ws/user_bg.png" mode="widthFix"></image>
  19. </view>
  20. <!-- 机构信息END -->
  21. <!-- 订单状态区域 -->
  22. <view class="order-wrap">
  23. <view class="more">
  24. <text class="title">我的订单</text>
  25. <view @click="navigator('/pages/user/order/order-list?state=0')">
  26. <text class="more-right">全部订单</text>
  27. <text class="iconfont icon-chakangengduo"></text>
  28. </view>
  29. </view>
  30. <view class="line"></view>
  31. <!-- 菜单选项 -->
  32. <view class="order-nav">
  33. <view
  34. class="order-nav-item"
  35. @click="navigator('/pages/user/order/order-list?state=1')"
  36. >
  37. <image src="@/static/ws/dh_dfk_02.png" mode="widthFix"></image>
  38. <text>待付款</text>
  39. </view>
  40. <view
  41. class="order-nav-item"
  42. @click="navigator('/pages/user/order/order-list?state=2')"
  43. >
  44. <image src="@/static/ws/dh_dfh_03.png" mode="widthFix"></image>
  45. <text>待发货</text>
  46. </view>
  47. <view
  48. class="order-nav-item"
  49. @click="navigator('/pages/user/order/order-list?state=3')"
  50. >
  51. <image src="@/static/ws/dh_yfh_04.png" mode="widthFix"></image>
  52. <text>已发货</text>
  53. </view>
  54. <view
  55. class="order-nav-item"
  56. @click="navigator('/pages/user/order/order-list?state=4')"
  57. >
  58. <image src="@/static/ws/dh_tk_05.png" mode="widthFix"></image>
  59. <text>退货/款</text>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 订单状态区域END -->
  64. <!-- 帮机构下单 -->
  65. <view class="place-order" @click="navigator('/pages/user/club/club-list')">
  66. <view class="place-left">
  67. <text class="iconfont icon-bangjigouxiadan"></text>
  68. <text class="title">帮机构下单</text>
  69. </view>
  70. <text class="iconfont icon-chakangengduo"></text>
  71. </view>
  72. <!-- 帮机构下单END -->
  73. <!-- 客服 -->
  74. <button class="ws-service" open-type="contact" @bindcontact="handleContact">
  75. <text class="iconfont icon-zaixiankefu"></text> 在线客服
  76. </button>
  77. </view>
  78. </template>
  79. <script>
  80. import { mapState, mapMutations } from 'vuex'
  81. import uniBadge from '@/components/uni-badge/uni-badge.vue'
  82. import upgradeAlert from '@/components/cm-module/modelAlert/upgradeAlert.vue'
  83. import authorize from '@/common/config/authorize.js'
  84. import wxLogin from '@/common/config/wxLogin.js'
  85. export default {
  86. components: {
  87. uniBadge,
  88. upgradeAlert
  89. },
  90. data() {
  91. return {
  92. nvabarData: {
  93. //顶部自定义导航
  94. showCapsule: 1, // 是否显示左上角图标 1表示显示 0表示不显示,
  95. showSearch: 0,
  96. title: '我的', // 导航栏 中间的标题
  97. haveBack: false,
  98. textLeft: this.$store.state.isIphone,
  99. textColor: '#FFFFFF',
  100. bgColor: ''
  101. },
  102. CustomBar: this.CustomBar, // 顶部导航栏高度
  103. StatusBar: this.StatusBar,
  104. isCmcustom: false,
  105. isUpgradeAlert: false,
  106. bgImgUrl:
  107. 'https://img.caimei365.com/group1/M00/03/B0/Cmis217Z_i6ASHobAAhl69yz3SM078.png',
  108. name: '',
  109. userType: '',
  110. headpic: '',
  111. userMoney: '0.00',
  112. contactNumber: '',
  113. openid: '',
  114. aboutHtml: '',
  115. telPhone: '',
  116. bindMobile: '',
  117. clubStatus: '', //机构升级会员机构审核状态1:待审核 91:审核失败
  118. userIdentity: '', //机构等级
  119. confirmedCount: 0, //待确认
  120. paymentCount: 0, //待付款角标
  121. waitShipmentsCount: 0, //待收货角标
  122. shipmentsCount: 0, //已发货角标
  123. salesReturnCount: '', //退货/款角标
  124. firstList: [
  125. {
  126. name: '帮机构下单',
  127. path: '/pages/user/club/club-list',
  128. icon: 'icon-yunyingrenyuanguanli'
  129. }
  130. ]
  131. }
  132. },
  133. onLoad() {
  134. authorize.getSetting().then(res => {
  135. // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  136. if (res == 1) {
  137. this.getWxAuthorize()
  138. } else {
  139. this.$api
  140. .getComStorage('userInfo')
  141. .then(resolve => {
  142. this.userID = resolve.userID ? resolve.userID : 0
  143. // this.getHomeInformation()
  144. })
  145. .catch(error => {
  146. // this.getHomeInformation()
  147. })
  148. }
  149. })
  150. },
  151. computed: {
  152. ...mapState(['hasLogin', 'userInfo'])
  153. },
  154. methods: {
  155. ...mapMutations(['login', 'logout']),
  156. // 获取授权
  157. getWxAuthorize() {
  158. authorize.getCode('weixin').then(wechatcode => {
  159. // 根据微信的code获取用户登录状态:1已登录过 -1未登录过
  160. authorize.getUserInfo('weixin').then(wxResponse => {
  161. this.UserService.userInfoLogin({ code: wechatcode })
  162. .then(response => {
  163. console.log(wechatcode)
  164. console.log(response)
  165. })
  166. .catch(error => {
  167. this.isLogin = false
  168. this.logout()
  169. this.$store.commit('updateStatus', error.data)
  170. })
  171. })
  172. })
  173. },
  174. // 客服
  175. handleContact(e) {
  176. console.log(e.detail.path)
  177. console.log(e.detail.query)
  178. },
  179. getUserInfo() {
  180. let self = this
  181. this.UserService.PersonalInfo({ userID: this.userID })
  182. .then(response => {
  183. this.$store.commit('updateAllNum', response.data.count)
  184. let data = response.data
  185. let $userData = data.user
  186. let $clubData = data.club
  187. if ($userData.ableUserMoney == 0 || $userData.ableUserMoney == null) {
  188. this.userMoney = '0.00'
  189. } else {
  190. let i = $userData.ableUserMoney.toString().lastIndexOf('.')
  191. let money
  192. if (i == -1) {
  193. money = this.$api.FormatMoney($userData.ableUserMoney) //会所剩余余额
  194. this.userMoney = money + '.00'
  195. } else {
  196. money = this.$api.FormatMoney($userData.ableUserMoney) //会所剩余余额
  197. this.userMoney = money
  198. }
  199. }
  200. this.userIdentity = $userData.userIdentity //机构等级
  201. if (this.userIdentity == 2) {
  202. this.name = $clubData.name //会员机构名称
  203. this.userType = '会员机构'
  204. } else {
  205. this.name = $userData.userName //普通机构名称
  206. this.userType = '普通机构'
  207. }
  208. this.headpic = $userData.image //会所头像
  209. this.bindMobile = $userData.bindMobile //登录手机号
  210. this.clubStatus = $userData.clubStatus //机构审核状态
  211. this.contactNumber = data.organize.contactNumber //联系电话
  212. this.confirmedCount = this.showBadge(data.confirmedCount) //待确认
  213. this.paymentCount = this.showBadge(data.paymentCount) //待付款
  214. this.waitShipmentsCount = this.showBadge(data.waitShipmentsCount) //待收货
  215. this.shipmentsCount = this.showBadge(data.shipmentsCount) //已发货
  216. this.salesReturnCount = this.showBadge(data.salesReturnCount) //退货/款
  217. let clubInfo = {
  218. name: this.name,
  219. image: this.headpic,
  220. clubID: $clubData.clubID
  221. }
  222. if ($userData.tipStatus == '0') {
  223. this.isUpgradeAlert = true
  224. }
  225. uni.setStorage({ key: 'clubInfo', data: clubInfo })
  226. })
  227. .catch(error => {
  228. this.$util.msg(error.msg, 2000)
  229. })
  230. },
  231. getPhone() {
  232. this.CommonService.QueryAfterSale()
  233. .then(response => {
  234. this.contactNumber = response.data.contactNumber
  235. })
  236. .catch(error => {
  237. this.$util.msg(error.msg, 2000)
  238. })
  239. },
  240. toPhone() {
  241. uni.makePhoneCall({
  242. phoneNumber: this.contactNumber //仅为示例
  243. })
  244. },
  245. hanldUnBindUpgrade() {
  246. //普通用户不升级会员机构
  247. cancelPrompt({ userId: this.userID }).then(response => {
  248. this.isUpgradeAlert = false
  249. })
  250. },
  251. hanldGoApply() {
  252. cancelPrompt({ userId: this.userID }).then(response => {
  253. this.isUpgradeAlert = false
  254. this.$api.navigateTo(`/pages/login/apply?clubStatus=${this.clubStatus}`)
  255. })
  256. },
  257. navigator(url) {
  258. authorize.getSetting().then(wxResponse => {
  259. // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  260. if (wxResponse == 1) {
  261. if (this.hasLogin) {
  262. this.$api.navigateTo(url)
  263. } else {
  264. this.$api.navigateTo('/pages/login/login?type=0')
  265. }
  266. } else {
  267. this.$api.navigateTo('/pages/authorization/authorization?type=1')
  268. }
  269. })
  270. },
  271. navigatorNex(url, type) {
  272. authorize.getSetting().then(wxResponse => {
  273. // console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
  274. if (wxResponse == 1) {
  275. if (!this.hasLogin) {
  276. this.$api.navigateTo(url)
  277. }
  278. } else {
  279. this.$api.navigateTo(`/pages/authorization/authorization?type=${type}`)
  280. }
  281. })
  282. },
  283. showBadge(n) {
  284. let num = ''
  285. if (n > 100) {
  286. num = 99
  287. } else {
  288. num = n
  289. }
  290. return num
  291. },
  292. clubStatusText(state) {
  293. let stateText
  294. switch (state) {
  295. case 90:
  296. stateText = ''
  297. break
  298. case 1:
  299. stateText = '正在审核中'
  300. break
  301. case 92:
  302. stateText = '审核不通过'
  303. break
  304. }
  305. return stateText
  306. }
  307. },
  308. onPageScroll(e) {
  309. //实时获取到滚动的值
  310. if (e.scrollTop > 20) {
  311. this.isCmcustom = true
  312. this.nvabarData.bgColor = '#E37A4B'
  313. this.nvabarData.textColor = '#FFFFFF'
  314. } else {
  315. this.isCmcustom = false
  316. this.nvabarData.bgColor = ''
  317. this.nvabarData.textColor = '#FFFFFF'
  318. }
  319. },
  320. onPullDownRefresh() {
  321. //下拉刷新
  322. if (this.hasLogin) {
  323. this.getUserInfo()
  324. uni.stopPullDownRefresh()
  325. } else {
  326. uni.stopPullDownRefresh()
  327. }
  328. },
  329. onShow() {
  330. }
  331. }
  332. </script>
  333. <style lang="scss">
  334. @import '@/uni.scss';
  335. .container {
  336. background: #f7f7f7;
  337. }
  338. // 用户登录信息区域
  339. .ws-header {
  340. position: relative;
  341. height: 280rpx;
  342. .user-info {
  343. position: absolute;
  344. z-index: 10;
  345. width: 750rpx;
  346. height: 280rpx;
  347. display: flex;
  348. flex-direction: column;
  349. align-items: center;
  350. justify-content: center;
  351. image {
  352. display: block;
  353. width: 120rpx;
  354. height: 120rpx;
  355. border-radius: 50%;
  356. }
  357. }
  358. // 登录按钮
  359. .ws-login {
  360. width: 184rpx;
  361. height: 56rpx;
  362. margin-top: 25rpx;
  363. border-radius: 28rpx;
  364. background: linear-gradient(to right, #fccd90, #b6762f);
  365. line-height: 56rpx;
  366. text-align: center;
  367. color: #ffffff;
  368. font-size: 28rpx;
  369. }
  370. // 公司名
  371. .user-text {
  372. width: 446rpx;
  373. margin-top: 25rpx;
  374. color: #fff;
  375. font-size: 28rpx;
  376. line-height: 40rpx;
  377. text-align: center;
  378. white-space: nowrap;
  379. overflow: hidden;
  380. text-overflow: ellipsis;
  381. }
  382. .user-bg {
  383. width: 100%;
  384. }
  385. }
  386. .more {
  387. width: 750rpx;
  388. display: flex;
  389. justify-content: space-between;
  390. align-items: center;
  391. padding: 23rpx 25rpx;
  392. box-sizing: border-box;
  393. background: #fff;
  394. .more-right {
  395. font-size: 26rpx;
  396. line-height: 37rpx;
  397. margin-right: 10rpx;
  398. }
  399. .title {
  400. font-size: 32rpx;
  401. line-height: 45rpx;
  402. color: #333333;
  403. }
  404. .iconfont {
  405. font-size: 20rpx;
  406. vertical-align: middle;
  407. }
  408. }
  409. .order-wrap {
  410. background: #fff;
  411. .line {
  412. width: 702rpx;
  413. height: 1px;
  414. margin: 0 auto;
  415. background: #f0f0f0;
  416. }
  417. .order-nav {
  418. display: flex;
  419. justify-content: space-evenly;
  420. align-items: center;
  421. padding: 40rpx 0;
  422. .order-nav-item {
  423. display: flex;
  424. align-items: center;
  425. flex-direction: column;
  426. image {
  427. width: 56rpx;
  428. height: 56rpx;
  429. }
  430. text {
  431. font-size: 26rpx;
  432. line-height: 37rpx;
  433. margin-top: 8rpx;
  434. }
  435. }
  436. }
  437. }
  438. .place-order {
  439. width: 750rpx;
  440. display: flex;
  441. justify-content: space-between;
  442. align-items: center;
  443. padding: 23rpx 25rpx;
  444. box-sizing: border-box;
  445. background: #fff;
  446. margin-top: 20rpx;
  447. .place-left {
  448. .title {
  449. font-size: 28rpx;
  450. line-height: 40rpx;
  451. margin-left: 10rpx;
  452. }
  453. .iconfont {
  454. font-size: 36rpx;
  455. vertical-align: middle;
  456. }
  457. }
  458. .iconfont {
  459. font-size: 20rpx;
  460. }
  461. }
  462. .ws-service {
  463. width: 160rpx;
  464. height: 48rpx;
  465. margin: 40rpx auto 0;
  466. display: flex;
  467. justify-content: center;
  468. align-items: center;
  469. font-size: 22rpx;
  470. background: linear-gradient(to right, #fccd90, #b6762f);
  471. color: #fff;
  472. border-radius: 24rpx;
  473. .iconfont {
  474. font-size: 30rpx;
  475. margin-right: 6rpx;
  476. }
  477. }
  478. </style>