Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

operation-upload.vue 6.8KB

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