order-addpay.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view class="container qualifications">
  3. <view class="qualifications-content">
  4. <view class="list-view-title"><text class="none">*</text>支付凭证图片:</view>
  5. <view class="list-view-upload clearfix">
  6. <view class="photo-item" v-for="(item, imageIndex) in imageList" :key="imageIndex">
  7. <image :src="item" mode="aspectFill" @click.stop="previewImg(item)"></image>
  8. <text class="iconfont icon-iconfontguanbi" @click.stop="deletePhotoFn(imageIndex)"></text>
  9. </view>
  10. <view
  11. class="photo-item add"
  12. @click.stop="uploadPhotoFn"
  13. v-if="imageList.length < 5 || imageList.length == 0"
  14. >
  15. <text class="iconfont icon-jiahao"></text>
  16. </view>
  17. </view>
  18. <view class="list-view-title">备注:</view>
  19. <view class="list-view-text">
  20. <textarea
  21. class="textarea"
  22. v-model="params.remarks"
  23. placeholder="请输入备注信息"
  24. maxlength="200"
  25. @input="conInput"
  26. />
  27. <text class="limit-text">{{ min }}/{{ max }}</text>
  28. </view>
  29. </view>
  30. <view class="card-mains-btn">
  31. <button
  32. class="add-btn"
  33. :disabled="disabled"
  34. :class="[disabled ? 'disabled' : '']"
  35. @click="orderInsertVoucher"
  36. >
  37. 提交
  38. </button>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import { mapState, mapMutations } from 'vuex'
  44. import { uploadFileImage } from '@/services/public.js'
  45. export default {
  46. data() {
  47. return {
  48. isIphoneX: this.$store.state.isIphoneX,
  49. isPreviewImg: false,
  50. imageList: [],
  51. params: {
  52. id: 0,
  53. orderId: 0,
  54. remarks: '',
  55. voucherImgs: ''
  56. },
  57. min: 0,
  58. max: 200
  59. }
  60. },
  61. onLoad(option) {
  62. console.log(option)
  63. this.params.orderId = option.orderId
  64. },
  65. computed: {
  66. disabled() {
  67. return !(this.imageList.length > 0)
  68. }
  69. },
  70. methods: {
  71. async orderInsertVoucher() {
  72. try {
  73. this.params.voucherImgs = this.imageList.join('##')
  74. console.log('params', this.params)
  75. const res = await this.OrderService.orderInsertVoucher(this.params)
  76. this.$util.msg('保存成功', 2000, true, 'success')
  77. setTimeout(() => {
  78. this.$api.navigateBack(1)
  79. }, 2000)
  80. } catch (error) {
  81. console.log('error', error)
  82. }
  83. },
  84. async uploadPhotoFn() {
  85. //添加图片
  86. try {
  87. const res = await uploadFileImage()
  88. const data = JSON.parse(res.data).data
  89. this.imageList.push(data)
  90. console.log('imageList', this.imageList)
  91. } catch (e) {
  92. console.log('1111111111')
  93. }
  94. },
  95. conInput(e) {
  96. //备注文字字数限制
  97. let value = e.detail.value
  98. let len = parseInt(value.length)
  99. if (len > this.max) return
  100. this.min = len
  101. if (this.min == 200) {
  102. return
  103. }
  104. },
  105. deletePhotoFn(index) {
  106. //删除图片
  107. this.imageList.splice(index, 1)
  108. },
  109. previewImg(image) {
  110. //顶部商品图片预览
  111. this.isPreviewImage = true
  112. let urls = []
  113. urls.push(image)
  114. uni.previewImage({
  115. urls: urls,
  116. current: 0
  117. })
  118. }
  119. },
  120. onShow() {}
  121. }
  122. </script>
  123. <style lang="scss">
  124. page {
  125. height: auto;
  126. background: #ffffff;
  127. }
  128. .qualifications-content {
  129. width: 100%;
  130. height: auto;
  131. box-sizing: border-box;
  132. padding: 0 24rpx;
  133. .list-view-title {
  134. width: 100%;
  135. height: 92rpx;
  136. line-height: 92rpx;
  137. font-size: $font-size-30;
  138. color: #333333;
  139. text-align: left;
  140. .none {
  141. color: #f85050;
  142. }
  143. }
  144. .list-view-text {
  145. width: 100%;
  146. height: 216rpx;
  147. box-sizing: border-box;
  148. border: 1px solid #e1e1e1;
  149. padding: 20rpx;
  150. border-radius: 6rpx;
  151. position: relative;
  152. .textarea {
  153. width: 100%;
  154. height: 100%;
  155. font-size: $font-size-26;
  156. color: #666666;
  157. }
  158. .limit-text {
  159. position: absolute;
  160. right: 20rpx;
  161. bottom: 16rpx;
  162. line-height: 44rpx;
  163. font-size: $font-size-24;
  164. color: #b2b2b2;
  165. }
  166. }
  167. .list-view-upload {
  168. width: 100%;
  169. height: auto;
  170. padding: 10rpx 0;
  171. .photo-item {
  172. display: inline-block;
  173. width: 150rpx;
  174. height: 150rpx;
  175. margin: 10rpx 0;
  176. margin-right: 25rpx;
  177. border-radius: 10rpx;
  178. border: 1px dashed #b8bfca;
  179. position: relative;
  180. float: left;
  181. &.add {
  182. width: 150rpx;
  183. height: 150rpx;
  184. border-color: #b2b2b2;
  185. text-align: center;
  186. line-height: 150rpx;
  187. margin-right: 0rpx;
  188. .icon-jiahao {
  189. font-size: $font-size-44;
  190. color: #b2b2b2;
  191. font-weight: bold;
  192. }
  193. }
  194. .icon-iconfontguanbi {
  195. width: 30rpx;
  196. height: 30rpx;
  197. border-radius: 50%;
  198. display: block;
  199. position: absolute;
  200. right: -10rpx;
  201. top: -10rpx;
  202. background: #f94b4b;
  203. text-align: center;
  204. line-height: 30rpx;
  205. color: #ffffff;
  206. font-size: $font-size-22;
  207. }
  208. image {
  209. width: 100%;
  210. height: 100%;
  211. border-radius: 10rpx;
  212. display: block;
  213. }
  214. }
  215. .photo-list {
  216. width: 100%;
  217. height: 116rpx;
  218. overflow: hidden;
  219. white-space: nowrap;
  220. display: flex;
  221. align-items: flex-start;
  222. }
  223. .scoll-wrapper {
  224. display: flex;
  225. align-items: flex-start;
  226. }
  227. }
  228. }
  229. .card-mains-btn {
  230. width: 100%;
  231. height: auto;
  232. box-sizing: border-box;
  233. padding: 0 75rpx;
  234. margin-top: 180rpx;
  235. .add-btn {
  236. width: 100%;
  237. height: 90rpx;
  238. font-size: $font-size-30;
  239. line-height: 90rpx;
  240. color: #ffffff;
  241. text-align: center;
  242. background: $btn-confirm;
  243. border-radius: 45rpx;
  244. border-radius: 44rpx;
  245. margin-top: 80rpx;
  246. &.disabled {
  247. background: #e1e1e1;
  248. border-radius: 44rpx;
  249. }
  250. }
  251. }
  252. </style>