You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

operation-upload.vue 8.1KB

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