quickMark.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <!-- 添加钢瓶扫描二维码 -->
  3. <view>
  4. <u-navbar :title="navTitle" autoBack placeholder></u-navbar>
  5. <view class="card_head_mark">
  6. <view class="card_sys" @click="sweep()">
  7. <u-icon name="scan" size="60" color="#18b566"></u-icon>
  8. <view class="sys_title">扫一扫</view>
  9. </view>
  10. </view>
  11. <view style="margin-top: 30rpx;" v-if="cylinderInformation.inner_code">
  12. <view class="card_quickmark" v-for="(item,index) in list" :key="index">
  13. <view class="quickmark_title width_quick">{{item.title}}</view>
  14. <view class="quickmark_title">{{cylinderInformation[`${item.key}`]}}</view>
  15. </view>
  16. </view>
  17. <view style="margin-top: 30rpx;" v-else>
  18. <u-empty mode="data" text="请先扫描钢瓶二维码"></u-empty>
  19. </view>
  20. <view class="card_btn">
  21. <u-button style="margin-bottom: 20rpx;" type="primary" @click="submit">添加钢瓶</u-button>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. navTitle: '',
  30. selectiveType: '',
  31. list: [{
  32. key: 'inner_code',
  33. title: '单位内编码:',
  34. }, {
  35. key: 'status',
  36. title: '气瓶状态:',
  37. }, {
  38. key: 'enterprise_name',
  39. title: '上次充装气站:',
  40. }, {
  41. key: 'fill_time',
  42. title: '上次充装时间:',
  43. }, {
  44. key: 'register_supervise_name',
  45. title: '使用登记审批单位:',
  46. }, {
  47. key: 'register_time',
  48. title: '使用登记日期:',
  49. }],
  50. cylinderInformation: {},
  51. }
  52. },
  53. onLoad(receive) {
  54. this.navTitle = receive.title
  55. this.selectiveType = receive.id
  56. },
  57. methods: {
  58. getList(qrid) {
  59. uni.showLoading({
  60. title: '加载中'
  61. });
  62. uni.request({
  63. url: 'http://qr.uinshine.com:9000/CommonAPI/product/getDetails', //仅为示例,并非真实接口地址。
  64. method: 'POST',
  65. header: {
  66. 'content-type': 'application/x-www-form-urlencoded', // 默认值
  67. },
  68. data: {
  69. qr_id: qrid,
  70. },
  71. success: (res) => {
  72. if (res.data.code == 0) {
  73. this.cylinderInformation = res.data.data
  74. uni.hideLoading();
  75. }
  76. }
  77. });
  78. },
  79. // 扫一扫
  80. sweep() {
  81. // const arr = 'http://qr.uinshine.com:9000/page/qrProduct.html?qr_id=1892e17a-1cfc-45c6-964e-41d1f1b9e42d'
  82. // 允许从相机和相册扫码
  83. uni.scanCode({
  84. scanType: ['qrCode'],
  85. autoZoom: false,
  86. success: (res) => {
  87. // console.log(res, '--------');
  88. if (res.result) {
  89. let url = res.result;
  90. const arrf = url.split('=')
  91. this.getList(arrf[1])
  92. } else {
  93. console.log('请重新扫描');
  94. return false;
  95. }
  96. },
  97. fail: (res) => {
  98. console.log('未识别到二维码1');
  99. }
  100. })
  101. },
  102. // 添加钢瓶
  103. submit() {
  104. if (this.cylinderInformation.inner_code) {
  105. this.$api.post('/api/gas-cylinder', {
  106. ...this.cylinderInformation,
  107. }).then(res => {
  108. if (res.code == 200) {
  109. this.cylinderInformation = {}
  110. uni.$u.toast('添加成功')
  111. }
  112. })
  113. } else {
  114. uni.$u.toast('请先扫描钢瓶二维码')
  115. }
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. .card_head_mark {
  122. display: flex;
  123. justify-content: center;
  124. padding-bottom: 30rpx;
  125. border-bottom: 2rpx solid #e4e7ed;
  126. }
  127. .card_sys {
  128. cursor: pointer;
  129. margin-top: 30rpx;
  130. display: flex;
  131. justify-content: center;
  132. align-items: center;
  133. flex-direction: column;
  134. width: 180rpx;
  135. height: 180rpx;
  136. border-radius: 20rpx;
  137. background-color: #f4f4f5;
  138. }
  139. .sys_title {
  140. font-size: 32rpx;
  141. color: #18b566;
  142. }
  143. .card_quickmark {
  144. display: inline-flex !important;
  145. word-break: break-all;
  146. width: calc(100% - 40rpx);
  147. margin: 10rpx 20rpx;
  148. }
  149. .width_quick {
  150. flex: none;
  151. }
  152. .quickmark_title {
  153. color: #249acc;
  154. font-size: 30rpx;
  155. margin-right: 10rpx;
  156. }
  157. .card_btn {
  158. position: fixed;
  159. left: 0;
  160. right: 0;
  161. bottom: 0;
  162. padding-left: 30rpx;
  163. padding-right: 30rpx;
  164. padding-top: 20rpx;
  165. background-color: #fff;
  166. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  167. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  168. }
  169. </style>