selectStore.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <!-- 选择门店 -->
  3. <view>
  4. <u-navbar border :title="navTitle" autoBack placeholder></u-navbar>
  5. <!-- <view v-if="treeData.length > 0">
  6. <tree-item v-for="item in treeData" :key="item.id" :item="item" @confirm="confirm"></tree-item>
  7. </view>
  8. <view style="margin-top: 30%;" v-else>
  9. <u-empty mode="list" text="门店列表为空"></u-empty>
  10. </view> -->
  11. <view class="card_head_mark">
  12. <view class="card_sys" @click="sweep()">
  13. <u-icon name="scan" size="60" color="#18b566"></u-icon>
  14. <view class="sys_title">扫一扫</view>
  15. </view>
  16. <view class="title_sad">扫描门店/气站二维码</view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import TreeItem from '@/components/TreeItem.vue';
  22. export default {
  23. components: {
  24. TreeItem
  25. },
  26. data() {
  27. return {
  28. treeData: [],
  29. navTitle: '',
  30. selectiveType: '',
  31. }
  32. },
  33. onLoad(receive) {
  34. this.navTitle = receive.title
  35. this.selectiveType = receive.id
  36. // this.getList()
  37. },
  38. methods: {
  39. // 扫一扫
  40. sweep() {
  41. // 允许从相机和相册扫码
  42. uni.scanCode({
  43. scanType: ['qrCode'],
  44. autoZoom: false,
  45. success: (res) => {
  46. if (res.result) {
  47. let url = res.result;
  48. const arrf = url.split(',')
  49. console.log(arrf, '--------');
  50. if (arrf.length > 3) {
  51. this.$cache.setCache('storeInformation', arrf)
  52. uni.navigateTo({
  53. url: '/pages/order/delivery?id=' + this.selectiveType + '&title=' +
  54. this.navTitle +
  55. '&cmpCode=' + arrf[0]
  56. });
  57. } else {
  58. uni.$u.toast('请扫描门店二维码')
  59. }
  60. } else {
  61. console.log('请重新扫描');
  62. return false;
  63. }
  64. },
  65. fail: (res) => {
  66. console.log('未识别到二维码1');
  67. }
  68. })
  69. },
  70. getList() {
  71. if (this.selectiveType == '25' || this.selectiveType == '27') {
  72. this.$api.get('/api/store/all2').then(res => {
  73. if (res.code == 200) {
  74. if (res.data) {
  75. this.treeData = res.data
  76. }
  77. }
  78. })
  79. } else {
  80. this.$api.get('/api/store/all').then(res => {
  81. if (res.code == 200) {
  82. if (res.data) {
  83. this.treeData = res.data
  84. }
  85. }
  86. })
  87. }
  88. },
  89. // 选择门店
  90. confirm(cmpCode) {
  91. uni.navigateTo({
  92. url: '/pages/order/delivery?id=' + this.selectiveType + '&title=' + this.navTitle +
  93. '&cmpCode=' + cmpCode
  94. });
  95. }
  96. }
  97. }
  98. </script>
  99. <style lang="scss">
  100. .card_head_mark {
  101. display: flex;
  102. justify-content: center;
  103. flex-direction: column;
  104. align-items: center;
  105. padding-bottom: 30rpx;
  106. border-bottom: 2rpx solid #e4e7ed;
  107. }
  108. .card_sys {
  109. cursor: pointer;
  110. margin-top: 30rpx;
  111. display: flex;
  112. justify-content: center;
  113. align-items: center;
  114. flex-direction: column;
  115. width: 180rpx;
  116. height: 180rpx;
  117. border-radius: 20rpx;
  118. background-color: #f4f4f5;
  119. }
  120. .sys_title {
  121. font-size: 32rpx;
  122. color: #18b566;
  123. }
  124. .title_sad {
  125. font-size: 30rpx;
  126. margin-top: 20rpx;
  127. }
  128. </style>