outBindCar.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view :style="colorStyle">
  3. <form @submit="formSubmit">
  4. <view class='personal-data'>
  5. <view class='list'>
  6. <view class='item acea-row row-between-wrapper'>
  7. <view>{{$t(`车牌号`)}}</view>
  8. <view class='input'>
  9. <input type='text' name='plate_number' v-model='carDateil.code' placeholder="车牌号/车辆编号二选一"
  10. class='id'></input>
  11. </view>
  12. </view>
  13. <view class='item acea-row row-between-wrapper'>
  14. <view>车辆编号</view>
  15. <view class='input acea-row row-between-wrapper'>
  16. <input type='text' name='machine_no' v-model='carDateil.machine_no'
  17. placeholder="车牌号/车辆编号二选一" class='id'></input>
  18. <!-- #ifndef H5 -->
  19. <text @click='openQr' class=' iconfont icon-saoma'></text>
  20. <!-- #endif -->
  21. </view>
  22. </view>
  23. <view class='item acea-row row-between-wrapper'>
  24. <view>{{$t(`类型`)}}</view>
  25. <view class='input'>
  26. <label class="radio" @click="type=0"><radio :checked="type==0" />解绑</label>
  27. <label @click="type=1" class="radio"><radio :checked="type==1"/>换绑</label>
  28. </view>
  29. </view>
  30. <view class='textarea'>
  31. <textarea v-model="carDateil.detail" :placeholder='$t(`请输入反馈内容`)' name="content"
  32. placeholder-class='placeholder'></textarea>
  33. </view>
  34. <view class='textarea'>
  35. <view class='list acea-row row-middle'>
  36. <view class='pictrue' v-for="(item,index) in pics" :key="index">
  37. <image :src='item'></image>
  38. <text class='iconfont icon-guanbi1 font-num' @click='DelPic(index)'></text>
  39. </view>
  40. <view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic'
  41. v-if="pics.length < 8">
  42. <text class='iconfont icon-icon25201'></text>
  43. <view>{{$t(`上传图片`)}}</view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <button class='modifyBnt bg-color' formType="submit">{{$t(`提交保存`)}}</button>
  50. </form>
  51. <canvas canvas-id="canvas" v-if="canvasStatus"
  52. :style="{width: canvasWidth + 'px', height: canvasHeight + 'px',position: 'absolute',left:'-100000px',top:'-100000px'}"></canvas>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. toLogin
  58. } from '@/libs/login.js';
  59. import {
  60. postStoreApplyId,
  61. } from '@/api/rent.js';
  62. import {
  63. mapGetters
  64. } from "vuex";
  65. import colors from '@/mixins/color.js';
  66. export default {
  67. mixins: [colors],
  68. data() {
  69. return {
  70. type: 0, //0解绑1换绑
  71. pics: [],
  72. id: '',
  73. carDateil: {
  74. machine_no: '',
  75. name: '',
  76. code: '',
  77. detail: '', //反馈内容
  78. id:0
  79. },
  80. canvasWidth: '',
  81. canvasHeight: '',
  82. canvasStatus: false
  83. };
  84. },
  85. computed: mapGetters(['isLogin']),
  86. onLoad(options) {
  87. if(this.type){
  88. uni.setNavigationBarTitle({
  89. title: '车辆换绑'
  90. });
  91. }else{
  92. uni.setNavigationBarTitle({
  93. title: '车辆解绑'
  94. });
  95. }
  96. if (!this.isLogin) {
  97. toLogin();
  98. }
  99. },
  100. methods: {
  101. /**
  102. * 删除图片
  103. *
  104. */
  105. DelPic: function(index) {
  106. let that = this,
  107. pic = this.pics[index];
  108. that.pics.splice(index, 1);
  109. that.$set(that, 'pics', that.pics);
  110. },
  111. /**
  112. * 上传文件
  113. *
  114. */
  115. uploadpic: function() {
  116. let that = this;
  117. this.canvasStatus = true
  118. that.$util.uploadImageChange('upload/image', function(res) {
  119. that.pics.push(res.data.url);
  120. }, (res) => {
  121. this.canvasStatus = false
  122. }, (res) => {
  123. this.canvasWidth = res.w
  124. this.canvasHeight = res.h
  125. });
  126. },
  127. // #ifndef H5
  128. // 打开二维码
  129. openQr() {
  130. const that = this;
  131. uni.scanCode({
  132. onlyFromCamera: true,
  133. scanType: ['barCode', 'qrCode', 'datamatrix', 'pdf417'],
  134. success(res) {
  135. that.carDateil.machine_no = res.result;
  136. }
  137. })
  138. },
  139. // #endif
  140. // 提交绑定
  141. formSubmit(data) {
  142. const value = data.detail.value
  143. uni.showLoading({
  144. title: '绑定中',
  145. mask: true
  146. });
  147. if(!value.machine_no&&!value.plate_number){
  148. uni.showToast({
  149. title: '车牌号或编号必须填一个',
  150. icon: 'error'
  151. });
  152. return
  153. }
  154. postStoreApplyId({
  155. machine_no: value.machine_no,
  156. content: value.content,
  157. images: this.pics,
  158. plate_number: value.plate_number,
  159. id: this.carDateil.id,
  160. type:this.type
  161. }).then((res) => {
  162. uni.hideLoading()
  163. uni.showToast({
  164. title: res.msg
  165. });
  166. setTimeout(() => {
  167. uni.redirectTo({
  168. url: '/pages/rent/store/outBindCarList'
  169. })
  170. }, 1000);
  171. }).catch((res) => {
  172. uni.hideLoading()
  173. uni.showToast({
  174. title: res,
  175. icon: 'error'
  176. });
  177. })
  178. },
  179. }
  180. }
  181. </script>
  182. <style scoped lang="scss">
  183. .personal-data .list {
  184. /* #ifndef H5 */
  185. margin-top: 15rpx;
  186. /* #endif */
  187. background-color: #fff;
  188. .item {
  189. padding: 30rpx 30rpx 30rpx 0;
  190. border-bottom: 1rpx solid #f2f2f2;
  191. margin-left: 30rpx;
  192. font-size: 28rpx;
  193. color: #282828;
  194. .input {
  195. text-align: right;
  196. color: #868686;
  197. .radio{
  198. margin-left: 20rpx;
  199. }
  200. .icon-suozi {
  201. margin-left: 10rpx;
  202. }
  203. .id {
  204. // width: 180rpx;
  205. }
  206. .iconfont {
  207. font-size: 36rpx;
  208. padding-left: 10rpx;
  209. }
  210. }
  211. }
  212. }
  213. .modifyBnt {
  214. font-size: 32rpx;
  215. color: #fff;
  216. width: 690rpx;
  217. height: 90rpx;
  218. border-radius: 50rpx;
  219. text-align: center;
  220. line-height: 90rpx;
  221. margin: 76rpx auto 0 auto;
  222. }
  223. .textarea {
  224. width: 690rpx;
  225. background-color: #fafafa;
  226. border-radius: 10rpx;
  227. margin-left: 30rpx;
  228. margin-top: 30rpx;
  229. textarea {
  230. font-size: 28rpx;
  231. padding: 20rpx 8rpx 0 8rpx;
  232. width: 100%;
  233. box-sizing: border-box;
  234. height: 160rpx;
  235. }
  236. .placeholder {
  237. color: #bbb;
  238. }
  239. .list {
  240. padding-left: 5rpx;
  241. padding-bottom: 30rpx;
  242. .pictrue {
  243. width: 140rpx;
  244. height: 140rpx;
  245. position: relative;
  246. font-size: 22rpx;
  247. color: #bbb;
  248. margin-right: 30rpx;
  249. &:nth-last-child(1) {
  250. border: 1rpx solid #ddd;
  251. box-sizing: border-box;
  252. }
  253. image {
  254. width: 100%;
  255. height: 100%;
  256. border-radius: 3rpx;
  257. }
  258. .icon-guanbi1 {
  259. font-size: 45rpx;
  260. position: absolute;
  261. top: -20rpx;
  262. right: -20rpx;
  263. }
  264. .icon-icon25201 {
  265. color: #bfbfbf;
  266. font-size: 50rpx;
  267. }
  268. }
  269. }
  270. }
  271. </style>