Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

operation-upload.vue 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <!-- 设备激活2-上传图片 -->
  2. <template>
  3. <view class="main" :style="{height: height+'px'}">
  4. <view class="item-row">
  5. <view class="item-left">
  6. <view class="title">车头照</view>
  7. <view class="desc">上传汽车的车头照片</view>
  8. <view class="flag"><text>拍摄示例</text> </view>
  9. </view>
  10. <view class="item-right" @click="chooseImage(1)">
  11. <view class="empty-node"></view>
  12. <image :src="state.headstockImg ?? defHeadstockImg" :data-url="state.headstockImg ?? defHeadstockImg">
  13. </image>
  14. </view>
  15. </view>
  16. <view class="item-row">
  17. <view class="item-left">
  18. <view class="title">安装照</view>
  19. <view class="desc">上传安装照片</view>
  20. <view class="flag"><text>拍摄示例</text> </view>
  21. </view>
  22. <view class="item-right" @click="chooseImage(2)">
  23. <view class="empty-node"></view>
  24. <image :src="state.installImg ?? defInstallImg"></image>
  25. </view>
  26. </view>
  27. <view class="hint">
  28. <image :src="`${$imgUrl}common/icon-hint.png`" class="icon"></image>
  29. <view>请打开手机蓝牙后再进行下一步操作。</view>
  30. </view>
  31. <view class="btn">
  32. <submit-button @submit="gotoNextStep" title="下一步"></submit-button>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup>
  37. import {
  38. reactive
  39. } from "vue";
  40. import {
  41. msg,
  42. navTo
  43. } from '@/utils/utils';
  44. import {
  45. fileURL
  46. } from "@/datas/fileURL.js";
  47. import {
  48. getItem
  49. } from "../../utils/storage";
  50. const imgURL = `${fileURL}image/`;
  51. import {
  52. request
  53. } from "../../utils/network/request.js";
  54. import {
  55. stringToJson
  56. } from "../../utils/network/encryption.js";
  57. import {
  58. upLoadImg
  59. } from "../../utils/network/api.js";
  60. import {
  61. onLoad
  62. } from '@dcloudio/uni-app'
  63. const height = uni.getSystemInfoSync().windowHeight
  64. const defHeadstockImg = imgURL + "bluetooth/device-active-img1.png";
  65. const defInstallImg = imgURL + "bluetooth/device-active-img2.png";
  66. const state = reactive({
  67. headstockImg: null, //车头照
  68. installImg: null, //安装照
  69. id: null,
  70. orderId: null,
  71. openId: null,
  72. });
  73. onLoad(() => {
  74. //读取传入 存储的数据orderInfo
  75. let orderData = getItem("orderInfo");
  76. state.id = orderData.id;
  77. state.orderId = orderData.orderId;
  78. state.openId = getItem("openId");
  79. console.log(state);
  80. })
  81. //选择图片
  82. const chooseImage = (type) => {
  83. uni.chooseImage({
  84. count: 1,
  85. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  86. //sourceType: ['album','camera'],
  87. success: function(res) {
  88. console.log(res.tempFilePaths);
  89. if (type === 1) { //车头照
  90. state.headstockImg = res.tempFilePaths[0];
  91. } else { //安装照
  92. state.installImg = res.tempFilePaths[0];
  93. }
  94. }
  95. });
  96. }
  97. //下一步
  98. const gotoNextStep = () => {
  99. if (!state.headstockImg || !state.installImg) {
  100. msg('请按照要求上传图片!');
  101. return;
  102. }
  103. uni.openBluetoothAdapter()
  104. /* 判断是否打开蓝牙 */
  105. uni.getBluetoothAdapterState({
  106. success(res) {
  107. //如果res.avaliable==false 说明没打开蓝牙 反之则打开
  108. if (res.available == false) {
  109. uni.showToast({
  110. title: '请打开手机蓝牙',
  111. icon: "error",
  112. duration: 2000
  113. })
  114. return
  115. } else {
  116. const options = {
  117. type: 2,
  118. data: {
  119. orderId: state.orderId,
  120. vehicleHeadImgUrl: state.headstockImg,
  121. installImgUrl: state.installImg,
  122. orderSource: "WECHAT",
  123. openId: state.openId,
  124. },
  125. method: "POST",
  126. showLoading: true,
  127. };
  128. request(upLoadImg, options).then((res) => {
  129. const data = stringToJson(res.bizContent);
  130. console.log(data);
  131. // state.form.vehBodyUrl = data.data.url;
  132. navTo('/pages/bluetooth/bluetooth?routeType=1')
  133. });
  134. }
  135. }
  136. })
  137. }
  138. </script>
  139. <style>
  140. page {
  141. background: #F3F3F3;
  142. }
  143. </style>
  144. <style lang="scss" scoped>
  145. .main {
  146. overflow: hidden;
  147. .item-row {
  148. width: calc(100% - 60rpx);
  149. margin-left: 30rpx;
  150. display: flex;
  151. justify-content: space-between;
  152. margin-top: 30rpx;
  153. background: white;
  154. padding: 30rpx;
  155. border-radius: 20rpx;
  156. box-shadow: 0rpx 4rpx 13rpx 3rpx rgba(223, 223, 223, 0.8);
  157. .item-left {
  158. .title {
  159. font-size: 34rpx;
  160. color: #333;
  161. font-weight: bold;
  162. }
  163. .desc {
  164. font-size: 24rpx;
  165. color: #999;
  166. margin: 10rpx 0;
  167. }
  168. .flag {
  169. width: 110rpx;
  170. height: 45rpx;
  171. line-height: 42rpx;
  172. color: #0A8F8A;
  173. margin-top: 16rpx;
  174. border-radius: 6rpx;
  175. text-align: center;
  176. font-size: 20rpx;
  177. background: #D9F8F1;
  178. }
  179. }
  180. .item-right {
  181. width: 295rpx;
  182. height: 188rpx;
  183. position: relative;
  184. image {
  185. position: relative;
  186. z-index: 10;
  187. width: 100%;
  188. height: 188rpx;
  189. }
  190. &::before {
  191. content: '';
  192. position: absolute;
  193. width: 22rpx;
  194. height: 22rpx;
  195. border: 4rpx solid #21BEB1;
  196. border-bottom: none;
  197. border-right: none;
  198. z-index: 0;
  199. left: -4rpx;
  200. top: -4rpx;
  201. }
  202. &::after {
  203. content: '';
  204. position: absolute;
  205. width: 22rpx;
  206. height: 22rpx;
  207. border: 4rpx solid #21BEB1;
  208. border-top: none;
  209. border-right: none;
  210. z-index: 0;
  211. left: -4rpx;
  212. bottom: -4rpx;
  213. }
  214. }
  215. .empty-node {
  216. position: absolute;
  217. z-index: 0;
  218. width: 100%;
  219. height: 100%;
  220. &::before {
  221. content: '';
  222. position: absolute;
  223. width: 22rpx;
  224. height: 22rpx;
  225. border: 4rpx solid #21BEB1;
  226. border-left: none;
  227. border-bottom: none;
  228. z-index: 0;
  229. right: -4rpx;
  230. top: -4rpx;
  231. }
  232. &::after {
  233. content: '';
  234. position: absolute;
  235. width: 22rpx;
  236. height: 22rpx;
  237. border: 4rpx solid #21BEB1;
  238. border-top: none;
  239. border-left: none;
  240. z-index: 0;
  241. right: -4rpx;
  242. bottom: -4rpx;
  243. }
  244. }
  245. }
  246. .hint {
  247. display: flex;
  248. flex-direction: row;
  249. justify-content: center;
  250. font-size: 26rpx;
  251. color: #666666;
  252. padding: 0px 30rpx;
  253. margin-top: 60rpx;
  254. .icon {
  255. width: 36rpx;
  256. height: 36rpx;
  257. margin-right: 10rpx;
  258. }
  259. view {
  260. width: calc(100% - 36rpx);
  261. }
  262. }
  263. .btn {
  264. margin: 60rpx 40rpx;
  265. }
  266. }
  267. </style>