cartAciton.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view class="content padding-t-30">
  3. <view class="listBox">
  4. <view class="list">
  5. <view class="flex listItem">
  6. <view class="flex titleBox">
  7. <text class="title">店铺名称</text>
  8. </view>
  9. <view class="right flex">
  10. <text>{{shopAction.name}}</text>
  11. </view>
  12. </view>
  13. <view class="flex listItem">
  14. <view class="flex titleBox">
  15. <text class="title">车辆品牌</text>
  16. </view>
  17. <view class="right flex">
  18. <text>{{cartName}}</text>
  19. </view>
  20. </view>
  21. <view class="flex listItem">
  22. <view class="flex titleBox">
  23. <text class="title">客户名称</text>
  24. </view>
  25. <view class="right flex">
  26. <text>{{userName}}</text>
  27. </view>
  28. </view>
  29. <view class="flex listItem">
  30. <view class="flex titleBox">
  31. <text class="title">客户手机</text>
  32. </view>
  33. <view class="right flex">
  34. <text>{{userPhone}}</text>
  35. </view>
  36. </view>
  37. <view class="flex listItem">
  38. <view class="flex titleBox">
  39. <text class="title">车架号</text>
  40. </view>
  41. <view class="right flex">
  42. <input class="input" type="text" v-model="cartId" placeholder="请输入车架号"
  43. placeholder-class="placeholder" />
  44. <image @click="openScend" class="img margin-l-10" src="../../static/icon/scend.png"
  45. mode="widthFix"></image>
  46. </view>
  47. </view>
  48. <view class="flex listItem">
  49. <view class="flex titleBox">
  50. <text class="title">批次</text>
  51. </view>
  52. <view class="right flex">
  53. <picker class="input" mode="selector" range-key='name' :range="pcList" @change="changePc">
  54. <view class="flex items-right">
  55. <view class="margin-r-10" v-if="pcList.length>0">
  56. {{pcList[pcIndex].name}}
  57. </view>
  58. <image class="iconTip" src="../../static/icon/dom.png" mode="aspectFit"></image>
  59. </view>
  60. </picker>
  61. </view>
  62. </view>
  63. <view class="flex listItem">
  64. <view class="flex titleBox">
  65. <text class="title">型号</text>
  66. </view>
  67. <view class="right flex">
  68. <picker class="input" mode="selector" range-key='name' :range="typeList" @change="changeType">
  69. <view class="flex items-right">
  70. <view class="margin-r-10" v-if="typeList.length>0">{{typeList[tpyeIndex].name}}</view>
  71. <image class="iconTip" src="../../static/icon/dom.png" mode="aspectFit"></image>
  72. </view>
  73. </picker>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. <view :class="{bgGray:loding}" class="add-btn" @click="confirm">提交</view>
  79. </view>
  80. </template>
  81. <script>
  82. import {
  83. orderDetail,
  84. set_car_number,
  85. batch,
  86. carType
  87. } from '@/api/shop.js';
  88. // #ifdef H5
  89. import weixinObj from "@/plugin/jweixin-module/index.js";
  90. import {
  91. weixindata
  92. } from "../../utils/wxAuthorized.js"
  93. // #endif
  94. import {
  95. mapState
  96. } from 'vuex';
  97. export default {
  98. computed: {
  99. ...mapState('shop', ['shopAction'])
  100. },
  101. watch: {
  102. cartId(newValue, oldValue) {
  103. for (let i = 0; i < this.pcList.length; i++) {
  104. if(+this.pcList[i].lan == newValue.length){
  105. this.changePc({
  106. detail:{
  107. value:i
  108. }
  109. })
  110. break
  111. }
  112. }
  113. }
  114. },
  115. data() {
  116. return {
  117. pcIndex: 0, //当前选中的批次
  118. tpyeIndex: 0, //当前选中的类型
  119. cartId: '', //车架号
  120. userName: '',
  121. userPhone: '',
  122. cartName: '',
  123. orderid: '', //保存订单id
  124. loding: false, //啊判断是否上传中
  125. pcList: [], //车辆批次列表
  126. typeList: [] //车辆类型列表
  127. }
  128. },
  129. onLoad(option) {
  130. this.orderid = option.id;
  131. this.getOrderDetail();
  132. // 获取车辆批次
  133. this.batch();
  134. this.carType();
  135. },
  136. methods: {
  137. batch() {
  138. batch().then((e) => {
  139. this.pcList = e.data;
  140. console.log(e);
  141. }).catch((e) => {
  142. console.log(e);
  143. })
  144. },
  145. carType() {
  146. carType().then((e) => {
  147. this.typeList = e.data;
  148. console.log(e);
  149. })
  150. },
  151. // 车辆批次切换
  152. changePc(e) {
  153. this.pcIndex = e.detail.value;
  154. console.log(e, '切换');
  155. },
  156. // 车辆类型切换
  157. changeType(e) {
  158. this.tpyeIndex = e.detail.value;
  159. console.log(e, '切换');
  160. },
  161. // 提交事件
  162. confirm() {
  163. if (!this.cartId) {
  164. uni.showModal({
  165. title: '提示',
  166. content: '请扫码或输入车架号',
  167. showCancel: false,
  168. });
  169. return
  170. }
  171. if (this.loding) {
  172. return
  173. }
  174. this.loding = true;
  175. set_car_number({
  176. order_id: this.orderid,
  177. car_number: this.cartId,
  178. car_batch: this.pcList[this.pcIndex].value,
  179. car_type: this.typeList[this.tpyeIndex].value,
  180. }).then((e) => {
  181. this.loding = false;
  182. uni.showModal({
  183. title: '提示',
  184. content: '车辆激活成功过!',
  185. showCancel: false,
  186. success: res => {
  187. uni.navigateBack()
  188. },
  189. });
  190. console.log(e);
  191. }).catch((e) => {
  192. this.loding = false;
  193. console.log(e);
  194. })
  195. },
  196. getOrderDetail() {
  197. let that = this;
  198. orderDetail({}, that.orderid).then(({
  199. data
  200. }) => {
  201. that.userName = data.real_name;
  202. that.userPhone = data.user_phone;
  203. that.cartName = data._info[0].cart_info.productInfo.store_name
  204. console.log(data, '数据');
  205. }).catch((e) => {
  206. console.log(e);
  207. })
  208. },
  209. openScend() {
  210. let that = this;
  211. // #ifdef H5
  212. weixindata().then(() => {
  213. weixinObj.scanQRCode({
  214. needResult: 1,
  215. success: (data) => {
  216. that.cartId = data.resultStr;
  217. }
  218. });
  219. })
  220. // #endif
  221. // #ifndef H5
  222. uni.scanCode({
  223. success: (e) => {
  224. // 保存二维码
  225. that.cartId = e.result;
  226. console.log(e);
  227. },
  228. fail() {
  229. console.log(e);
  230. }
  231. })
  232. // #endif
  233. },
  234. }
  235. }
  236. </script>
  237. <style lang="scss">
  238. .listBox {
  239. margin: $page-row-spacing;
  240. border-radius: 20rpx;
  241. overflow: hidden;
  242. background-color: #FFFFFF;
  243. }
  244. .list {
  245. .listItem {
  246. padding: 35rpx 40rpx;
  247. border-bottom: 1px solid $page-color-light;
  248. .iconTip {
  249. width: 36rpx;
  250. height: 36rpx;
  251. }
  252. }
  253. .listIconImg {
  254. width: 36rpx;
  255. }
  256. .right {
  257. color: $font-color-light;
  258. font-size: $font-base;
  259. flex-grow: 1;
  260. justify-content: flex-end;
  261. padding-left: 20rpx;
  262. .img {
  263. width: 36rpx;
  264. }
  265. }
  266. .input {
  267. flex-grow: 1;
  268. text-align: right;
  269. font-size: $font-base;
  270. color: $color-gray;
  271. }
  272. .titleBox {
  273. flex-shrink: 0;
  274. .title {
  275. color: $font-color-base;
  276. font-size: $font-base;
  277. }
  278. }
  279. }
  280. .add-btn {
  281. background-color: $color-green;
  282. font-size: 28rpx;
  283. padding: 30rpx;
  284. color: #FFFFFF;
  285. margin: 0 50rpx;
  286. border-radius: 100rpx;
  287. margin-top: 100rpx;
  288. text-align: center;
  289. position: fixed;
  290. left: 30rpx;
  291. right: 30rpx;
  292. bottom: 30rpx;
  293. z-index: 95;
  294. &.bgGray {
  295. background-color: $font-color-disabled;
  296. }
  297. }
  298. </style>