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 6.8KB

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