status1.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view class="content">
  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. {{cartInfo.car_name}}
  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" @click="getAddress">
  18. <view class="input">
  19. {{address}}
  20. </view>
  21. <image class="img" src="../../../static/icon/location.png" mode="widthFix"></image>
  22. </view>
  23. </view>
  24. <view class="flex listItem">
  25. <view class="flex titleBox">
  26. <text class="title">联系电话</text>
  27. </view>
  28. <view class="right flex">
  29. <input class="input" v-model="phone" type="text" placeholder="请填写联系电话"
  30. placeholder-class="placeholder" />
  31. </view>
  32. </view>
  33. <view class="listItem">
  34. <view class="flex titleBox">
  35. <text class="title">故障简述</text>
  36. </view>
  37. <view class="right flex">
  38. <textarea class="textarea_text" placeholder="简单的描述下故障。" v-model="content" maxlength='300'
  39. name="" id="" cols="30" rows="10"></textarea>
  40. <view class="maxShow">
  41. {{content.length}}/300
  42. </view>
  43. </view>
  44. </view>
  45. <view class="listItem">
  46. <view class="flex titleBox">
  47. <text class="title">图片上传</text>
  48. </view>
  49. <view class="right flex imgList">
  50. <view class="position-relative margin-r-20" v-if="imgList.length>0"
  51. v-for="(item,index) in imgList">
  52. <image class="upImg" :src="item" mode="scaleToFill"></image>
  53. <image class="topExit" src="../../../static/icon/goodsExit.png" mode="scaleToFill"
  54. @click="delImg(index)"></image>
  55. </view>
  56. <view class="position-relative margin-r-20">
  57. <image class="upImg" src="../../../static/image/upImg.png" mode="scaleToFill"
  58. @click="upImg()"></image>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="base-buttom" @click="confirm">
  65. 申请报修
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import {
  71. create_question
  72. } from '@/api/user.js';
  73. import {
  74. upload
  75. } from '@/api/order.js';
  76. export default {
  77. props: {
  78. cartInfo: {
  79. type: Object,
  80. default: function() {
  81. return {}
  82. }
  83. }
  84. },
  85. data() {
  86. return {
  87. content: '', //提交内容
  88. cartName: '车辆编号asdsfqdqwew',
  89. phone: '', //手机号
  90. address: '', //定位
  91. lat: '', //经度
  92. lon: '', //纬度
  93. imgList: [],
  94. };
  95. },
  96. created() {
  97. // console.log('调用方法1');
  98. },
  99. methods: {
  100. // 提交审核
  101. confirm() {
  102. if (!this.phone || this.phone.length != 11) {
  103. uni.showModal({
  104. title: '提示',
  105. content: '请填写正确的手机号',
  106. showCancel: false,
  107. });
  108. return
  109. }
  110. if (!this.content || !(this.content.trim())) {
  111. uni.showModal({
  112. title: '提示',
  113. content: '请填写故障描述',
  114. showCancel: false,
  115. });
  116. }
  117. if (this.imgList.length < 1) {
  118. uni.showModal({
  119. title: '提示',
  120. content: '请上传故障图片',
  121. showCancel: false,
  122. });
  123. }
  124. uni.showLoading({
  125. title: '提交中',
  126. mask: true
  127. });
  128. create_question({
  129. car_number: this.cartInfo.car_number,
  130. phone: this.phone,
  131. content: this.content,
  132. images: this.imgList.join(','),
  133. longitude: this.lon,
  134. 'latitude': this.lat,
  135. address: this.address
  136. }).then((e) => {
  137. uni.showModal({
  138. title: '提示',
  139. content: e.msg,
  140. showCancel: false,
  141. });
  142. this.$emit("request");
  143. uni.hideLoading()
  144. }).catch((e) => {
  145. uni.hideLoading()
  146. })
  147. },
  148. // 上传修理图片
  149. upImg(type = 'add', index) {
  150. // console.log(type,index,'上传');
  151. let that = this;
  152. upload({
  153. filename: ''
  154. }).then(data => {
  155. // console.log(type == 'add');
  156. if (type == 'add') {
  157. that.imgList = that.imgList.concat([data[0].url]);
  158. }
  159. if (type == "edit") {
  160. that.imgList[index] = data[0].url;
  161. }
  162. })
  163. },
  164. // 获取用户地址信息
  165. getAddress() {
  166. let that = this;
  167. uni.getLocation({
  168. type:'gcj02',
  169. success(res) {
  170. // console.log(res, '返回的位置数据');
  171. uni.chooseLocation({
  172. latitude: res.latitude,
  173. longitude: res.longitude,
  174. success(re) {
  175. that.lat = re.latitude;
  176. that.lon = re.longitude;
  177. that.address = re.address;
  178. // console.log(re, '当前位置');
  179. },
  180. fail(e) {
  181. console.log(e, 'cw');
  182. }
  183. })
  184. }
  185. })
  186. },
  187. // 删除上传图片
  188. delImg(index) {
  189. this.imgList.splice(index, 1)
  190. }
  191. }
  192. }
  193. </script>
  194. <style lang="scss">
  195. page {
  196. height: 100%;
  197. }
  198. .listBox {
  199. margin: $page-row-spacing;
  200. margin-top: 30rpx;
  201. border-radius: 20rpx;
  202. overflow: hidden;
  203. background-color: #FFFFFF;
  204. }
  205. .list {
  206. .input {
  207. text-align: right;
  208. font-size: $font-base;
  209. color: $color-gray;
  210. width: 100%;
  211. }
  212. .listItem {
  213. padding: 35rpx 40rpx;
  214. border-bottom: 1px solid $page-color-light;
  215. .imgList {
  216. margin-top: 30rpx;
  217. justify-content: flex-start;
  218. .topExit {
  219. width: 30rpx;
  220. height: 30rpx;
  221. position: absolute;
  222. top: -10rpx;
  223. right: -10rpx;
  224. }
  225. }
  226. }
  227. .listIconImg {
  228. width: 36rpx;
  229. }
  230. .right {
  231. color: $font-color-light;
  232. font-size: $font-base;
  233. flex-grow: 1;
  234. justify-content: flex-end;
  235. position: relative;
  236. .img {
  237. width: 26rpx;
  238. }
  239. .upImg {
  240. width: 120rpx;
  241. height: 120rpx;
  242. border-radius: 20rpx;
  243. }
  244. .textarea_text {
  245. background-color: $page-color-base;
  246. width: 100%;
  247. margin-top: 30rpx;
  248. border-radius: 20rpx;
  249. padding: 30rpx;
  250. }
  251. .maxShow {
  252. position: absolute;
  253. bottom: 10rpx;
  254. right: 20rpx;
  255. font-size: 24rpx;
  256. }
  257. }
  258. .titleBox {
  259. .title {
  260. color: $font-color-base;
  261. font-size: $font-base;
  262. }
  263. }
  264. }
  265. </style>