index.vue 8.9 KB

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