index.vue 11 KB

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