quickMark.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. } else {
  76. uni.$u.toast(res.data.msg)
  77. uni.hideLoading();
  78. }
  79. }
  80. });
  81. },
  82. // 扫一扫
  83. sweep() {
  84. // const arr = 'http://qr.uinshine.com:9000/page/qrProduct.html?qr_id=1892e17a-1cfc-45c6-964e-41d1f1b9e42d'
  85. // 允许从相机和相册扫码
  86. uni.scanCode({
  87. scanType: ['qrCode'],
  88. autoZoom: false,
  89. success: (res) => {
  90. // console.log(res, '--------');
  91. if (res.result) {
  92. let url = res.result;
  93. const arrf = url.split('=')
  94. this.getList(arrf[1])
  95. } else {
  96. console.log('请重新扫描');
  97. return false;
  98. }
  99. },
  100. fail: (res) => {
  101. console.log('未识别到二维码1');
  102. }
  103. })
  104. },
  105. // 添加钢瓶
  106. submit() {
  107. if (this.cylinderInformation.inner_code) {
  108. uni.showLoading({
  109. mask: true,
  110. });
  111. this.$api.post('/api/gas-cylinder', {
  112. ...this.cylinderInformation,
  113. }).then(res => {
  114. if (res.code == 200) {
  115. this.cylinderInformation = {}
  116. uni.$u.toast('添加成功')
  117. }
  118. uni.hideLoading();
  119. }).catch(() => {
  120. uni.hideLoading();
  121. })
  122. } else {
  123. uni.$u.toast('请先扫描钢瓶二维码')
  124. }
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="scss">
  130. .card_head_mark {
  131. display: flex;
  132. justify-content: center;
  133. padding-bottom: 30rpx;
  134. border-bottom: 2rpx solid #e4e7ed;
  135. }
  136. .card_sys {
  137. cursor: pointer;
  138. margin-top: 30rpx;
  139. display: flex;
  140. justify-content: center;
  141. align-items: center;
  142. flex-direction: column;
  143. width: 180rpx;
  144. height: 180rpx;
  145. border-radius: 20rpx;
  146. background-color: #f4f4f5;
  147. }
  148. .sys_title {
  149. font-size: 32rpx;
  150. color: #18b566;
  151. }
  152. .card_quickmark {
  153. display: inline-flex !important;
  154. word-break: break-all;
  155. width: calc(100% - 40rpx);
  156. margin: 10rpx 20rpx;
  157. }
  158. .width_quick {
  159. flex: none;
  160. }
  161. .quickmark_title {
  162. color: #249acc;
  163. font-size: 30rpx;
  164. margin-right: 10rpx;
  165. }
  166. .card_btn {
  167. position: fixed;
  168. left: 0;
  169. right: 0;
  170. bottom: 0;
  171. padding-left: 30rpx;
  172. padding-right: 30rpx;
  173. padding-top: 20rpx;
  174. background-color: #fff;
  175. padding-bottom: constant(safe-area-inset-bottom); //兼容 IOS<11.2
  176. padding-bottom: env(safe-area-inset-bottom); //兼容 IOS>11.2
  177. }
  178. </style>