index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <view class="content">
  3. <!-- 用户信息 -->
  4. <view class="userCard flex align_center justify_between" @click="toUser">
  5. <view class="userCard-info flex align_center justify_between">
  6. <view>
  7. <u-image v-if="!hasLogin" src="/static/def_personal_avatar.png" width="60" height="60"></u-image>
  8. <open-data v-else type="userAvatarUrl" class="user-photo"></open-data>
  9. </view>
  10. <view>
  11. <view v-if="!hasLogin" style="font-size: 40rpx;">
  12. 请点击登录
  13. </view>
  14. <view v-else>
  15. <view>{{userInfo.userNameCN}}</view>
  16. <view>{{userInfo.orgName}}</view>
  17. </view>
  18. </view>
  19. </view>
  20. <view>
  21. <u-icon name="arrow-right"></u-icon>
  22. </view>
  23. </view>
  24. <!-- 套餐记录 -->
  25. <view class="list-box">
  26. <u-cell-group :border="false" v-if="hasLogin">
  27. <u-cell-item v-for="item in vinList" @click="toChoosePart(item)" :key="item.id" :title="item.vinCode" :title-style="{fontSize:'1em'}" :label="item.brandName +' '+item.modelName">
  28. <text slot="icon"></text>
  29. </u-cell-item>
  30. <view style="padding: 20upx;">
  31. <u-empty :src="`/static/nodata.png`" icon-size="180" :text="noDataText" img-width="120" v-if="vinList.length==0 && status!='loading'" mode="list"></u-empty>
  32. <u-loadmore v-if="status=='loading'" :status="status" />
  33. </view>
  34. </u-cell-group>
  35. <view class="des" v-if="!hasLogin">请登录后查看套餐记录</view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import {
  41. mapState,
  42. mapMutations,
  43. } from 'vuex'
  44. import { shelfBondRecordWaitPayRecord, findStoreShelf, shelfGetTotalWaitQty } from '@/api/shelf.js'
  45. import { listLookUp, getLookUpDatas } from '@/api/data.js';
  46. import { scanVinLogQueryRoll, getScanVinLogList }from '@/api/car.js'
  47. export default {
  48. components: {
  49. },
  50. data() {
  51. return {
  52. status: 'loading',
  53. noDataText: '暂无数据',
  54. bondRecord: null, // 保证金
  55. list:[],
  56. vinList: [],
  57. orderTodo: null,
  58. }
  59. },
  60. computed: {
  61. ...mapState(['hasLogin']),
  62. hasShelf(){
  63. return this.$store.state.vuex_storeShelf
  64. },
  65. userInfo(){
  66. return this.$store.state.vuex_userInfo
  67. }
  68. },
  69. onReady() {
  70. // 检测是否登录
  71. this.$store.dispatch('checkLogin',()=>{
  72. this.pageInit()
  73. })
  74. this.getScrollLog()
  75. },
  76. onLoad() {
  77. // 获取数据字典
  78. this.getListLookUp();
  79. // 获取支付,收款方式
  80. this.getLookUpList('PAY_PROCUCT_TYPE', 'vuex_paymentTypeList');
  81. // 刷新首页数据
  82. uni.$on("refashHome",()=>{
  83. this.pageInit()
  84. })
  85. },
  86. onUnload() {
  87. uni.$off('refashHome')
  88. },
  89. // 下拉刷新
  90. onPullDownRefresh(){
  91. this.pageInit()
  92. setTimeout(function () {
  93. uni.stopPullDownRefresh();
  94. }, 1000);
  95. },
  96. onShareAppMessage() {
  97. },
  98. methods: {
  99. pageInit(){
  100. if(this.hasLogin){
  101. // 查询是否有数字货架
  102. this.getStoreShelf()
  103. // 获取扫描记录
  104. this.getVinLog()
  105. }
  106. },
  107. // 获取数据字典
  108. getListLookUp() {
  109. const _this = this;
  110. listLookUp({ pageNo: 1, pageSize: 1000 }).then(res => {
  111. if (res.status == 200) {
  112. _this.$store.state.vuex_allLookUp = res.data;
  113. }
  114. });
  115. },
  116. // 或某一项字典列表,参数code
  117. getLookUpList(code, vuexKey) {
  118. getLookUpDatas({ type: code }).then(res => {
  119. if (res.status == 200) {
  120. this.$store.state[vuexKey] = res.data || [];
  121. }
  122. });
  123. },
  124. // 待取货数量合计
  125. shelfGetTotalWaitQty(){
  126. shelfGetTotalWaitQty({billState:'WAIT'}).then(res => {
  127. if(res.status == 200){
  128. this.orderTodo = res.data
  129. }
  130. })
  131. },
  132. // 货架订单列表
  133. toOrder(){
  134. if(this.hasShelf){
  135. uni.navigateTo({
  136. url: "/pages/digitalShelf/orderList"
  137. })
  138. }else{
  139. uni.showToast({
  140. icon:'none',
  141. title: '门店没有关联数字货架,无法使用此功能!'
  142. })
  143. }
  144. },
  145. getScrollLog(){
  146. scanVinLogQueryRoll({pageNo:1,pageSize:1000}).then(res => {
  147. this.list = res.data.list || []
  148. })
  149. },
  150. getVinLog(){
  151. this.vinList = []
  152. this.status = "loading"
  153. getScanVinLogList({pageNo:1,pageSize:10}).then(res => {
  154. this.vinList = res.data.list || []
  155. this.vinList = this.vinList.filter(item => item.vinCode)
  156. this.status = 'nomore'
  157. })
  158. },
  159. // 查询是否支持数字货架
  160. getStoreShelf(){
  161. findStoreShelf().then(res => {
  162. console.log(res)
  163. this.$store.state.vuex_storeShelf = res.data;
  164. if(res.data){
  165. // 保证金查询
  166. this.getShelfBWPayRecord()
  167. // 获取订单信息
  168. this.shelfGetTotalWaitQty()
  169. }
  170. })
  171. },
  172. // 获取保证金金额
  173. getShelfBWPayRecord(){
  174. const data = this.$store.state.vuex_storeShelf
  175. shelfBondRecordWaitPayRecord({shelfSn: data.shelfSn, storeSn: data.storeSn}).then(res => {
  176. console.log(res,'获取保证金金额')
  177. this.bondRecord = res.data
  178. })
  179. },
  180. // 保证金支付
  181. toPayBondAmount(){
  182. },
  183. // 去扫描
  184. openCamera(){
  185. uni.navigateTo({
  186. url: this.hasLogin ? "/pages/scan-frame/scan-frame" : '/pages/login/login'
  187. })
  188. },
  189. // 查看扫描记录
  190. toAllRecord(){
  191. uni.navigateTo({
  192. url: this.hasLogin ? "/pages/vinRecord/vinRecord" : '/pages/login/login'
  193. })
  194. },
  195. toUser(){
  196. uni.navigateTo({
  197. url: this.hasLogin ? '/pages/personData/personData' : '/pages/login/login'
  198. })
  199. },
  200. toChoosePart(item){
  201. if(this.hasShelf){
  202. item.text = item.modelInfo
  203. uni.navigateTo({
  204. url: "/pages/digitalShelf/choosePart?vinNumber="+item.vinCode+"&carList="+encodeURIComponent(JSON.stringify(item))
  205. })
  206. }else{
  207. uni.showToast({
  208. icon:'none',
  209. title: '门店没有关联数字货架,无法使用此功能!'
  210. })
  211. }
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="less">
  217. .content {
  218. margin: 0;
  219. padding: 0;
  220. height: 100vh;
  221. display: flex;
  222. flex-direction: column;
  223. .userCard{
  224. padding:1.2em 1em;
  225. background-image: linear-gradient(#58c4c4 10%,#65e2e2);
  226. .userCard-info{
  227. > view{
  228. &:last-child{
  229. margin-left: 0.5em;
  230. >view{
  231. padding: 0.2em;
  232. }
  233. }
  234. }
  235. }
  236. .user-photo{
  237. display: block;
  238. width: 120rpx;
  239. height: 120rpx;
  240. border-radius: 50%;
  241. overflow: hidden;
  242. }
  243. }
  244. .ml10{
  245. margin-left: 0.2em;
  246. }
  247. .list-box{
  248. flex-grow: 1;
  249. padding: 0 1em;
  250. overflow: auto;
  251. .des{
  252. text-align: center;
  253. padding: 3em 0;
  254. color: #999;
  255. font-size: 0.9em;
  256. }
  257. }
  258. }
  259. </style>