add.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <template>
  2. <view class="container qualifications" :style="{ paddingBottom: isIphoneX ? '68rpx' : '0' }">
  3. <view class="remarks-content">
  4. <view class="list-view-title">
  5. <view class="list-view-h1"><text>*</text>文字备注</view>
  6. </view>
  7. <view class="remarks-textarea">
  8. <textarea
  9. class="textarea"
  10. v-model="remarksParams.remarks"
  11. value=""
  12. placeholder="文字备注,500字以内"
  13. maxlength="500"
  14. @input="conInput"
  15. />
  16. <text class="limit-text">{{ min }}/{{ max }}</text>
  17. </view>
  18. <view class="list-view-title">
  19. <view class="list-view-h1">上传图片</view>
  20. <view class="list-view-p">(可上传与客户的聊天截图或其他重要图片资料,最多10张)</view>
  21. </view>
  22. <view class="list-view-upload clearfix">
  23. <view class="photo-item" v-for="(image, imageIndex) in remarksParams.imageList" :key="imageIndex">
  24. <image
  25. :src="image"
  26. mode="aspectFill"
  27. @click.stop="previewImg(remarksParams.imageList, imageIndex)"
  28. ></image>
  29. <text
  30. class="iconfont icon-iconfontguanbi"
  31. @click.stop="deletePhotoFn(remarksParams.imageList, imageIndex)"
  32. ></text>
  33. </view>
  34. <view
  35. class="photo-item add"
  36. @click.stop="uploadPhotoFn(remarksParams.imageList)"
  37. v-if="remarksParams.imageList.length < 10 || remarksParams.imageList.length == 0"
  38. >
  39. <text class="iconfont icon-jiahao"></text>
  40. </view>
  41. </view>
  42. <view class="list-view-title">
  43. <view class="list-view-h1">上传文件</view>
  44. <view class="list-view-p">(可上传与客户相关的文件资料,最多10份,支持word,excel,ppt和pdf格式文件)</view>
  45. </view>
  46. <view class="list-view" v-for="(file, fileIndex) in remarksParams.fileList" :key="fileIndex">
  47. <view class="list-view-text">
  48. <view class="input">{{ file.fileName }}</view>
  49. <view class="delbtn" @click.stop="deleteFileFn(remarksParams.fileList, fileIndex)">删除</view>
  50. </view>
  51. </view>
  52. <view class="list-view">
  53. <view class="list-view-file" @click="uploadFile(remarksParams.fileList)">选择文件</view>
  54. </view>
  55. </view>
  56. <view class="remarks-btn" :style="{ paddingBottom: isIphoneX ? '68rpx' : '0' }">
  57. <view class="edit-button" @click="editButtonConfim">确定</view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import { mapState, mapMutations } from 'vuex'
  63. import authorize from '@/common/config/authorize.js'
  64. import { uploadFileImage, uploadFilePdfDocDocx } from '@/services/public.js'
  65. var isPreviewImg
  66. export default {
  67. data() {
  68. return {
  69. isIphoneX: this.$store.state.isIphoneX,
  70. shopOrderId: 0,
  71. logisticsBatchId: 0,
  72. productActions: [],
  73. remarksParams: {
  74. clubId: 0,
  75. remarks: '',
  76. fileList: [],
  77. imageList: [],
  78. serviceProviderId: 0
  79. },
  80. min: 0,
  81. max: 500,
  82. handleType:''
  83. }
  84. },
  85. onLoad(option) {
  86. console.log(option)
  87. if (option.type == 'edit') {
  88. this.getUserClubRemarksDetail(option.remarksId)
  89. this.handleType = option.type
  90. } else {
  91. this.initGetStotage()
  92. }
  93. },
  94. methods: {
  95. ...mapMutations(['login']),
  96. async initGetStotage() {
  97. const clubInfo = await this.$api.getComStorage('orderUserInfo')
  98. const userInfo = await this.$api.getStorage()
  99. this.remarksParams.clubId = clubInfo.clubId ? clubInfo.clubId : 0
  100. this.remarksParams.serviceProviderId = userInfo.serviceProviderId ? userInfo.serviceProviderId : 0
  101. },
  102. getUserClubRemarksDetail(remarksId) {
  103. //修改回显资料备注信息
  104. this.UserService.getUserClubRemarksDetail({
  105. remarksId : remarksId
  106. })
  107. .then(response => {
  108. let data = response.data
  109. this.remarksParams.remarks = data.remarks
  110. this.remarksParams.remarksId = data.remarksId
  111. this.remarksParams.fileList = data.fileList
  112. this.remarksParams.imageList = data.imageList
  113. this.initGetStotage()
  114. })
  115. .catch(error => {
  116. this.$util.msg(error.msg, 2000)
  117. })
  118. },
  119. editButtonConfim() {
  120. //保存资料备注
  121. if (this.remarksParams.remarks == '') {
  122. this.$util.msg('请输入文字备注', 2000)
  123. return
  124. }
  125. console.log('remarksParams',this.remarksParams)
  126. console.log('remarksParams',JSON.stringify(this.remarksParams))
  127. this.UserService.getUserClubRemarksSave({
  128. params: JSON.stringify(this.remarksParams)
  129. })
  130. .then(response => {
  131. this.$util.msg('添加成功', 3000, true, 'success')
  132. setTimeout(() => {
  133. this.$api.navigateTo('/pages/seller/remarks/list')
  134. }, 2000)
  135. })
  136. .catch(error => {
  137. this.$util.msg(error.msg, 2000)
  138. })
  139. },
  140. uploadFile(array) {
  141. //上传资质文件
  142. console.log(array)
  143. uploadFilePdfDocDocx().then(res => {
  144. let data = JSON.parse(res.data).data
  145. let obj = {
  146. fileName: uni.getStorageSync('fileName'),
  147. ossName: data.ossName
  148. }
  149. array.push(obj)
  150. console.log('array', array)
  151. })
  152. },
  153. uploadPhotoFn(array) {
  154. //添加图片
  155. uploadFileImage().then(res => {
  156. array.push(JSON.parse(res.data).data)
  157. })
  158. },
  159. deleteFileFn(array, index) {
  160. console.log(array)
  161. //删除文件
  162. this.UploadService.PostFileDelete({
  163. ossName: array[index].ossName
  164. })
  165. .then(res => {
  166. array.splice(index, 1)
  167. })
  168. .catch(error => {
  169. console.log('删除文件异常提示===>', error.msg)
  170. })
  171. },
  172. deletePhotoFn(array, index) {
  173. //删除图片
  174. array.splice(index, 1)
  175. },
  176. previewImg(image, index) {
  177. //顶部商品图片预览
  178. isPreviewImg = true
  179. let previewUrls = image
  180. uni.previewImage({
  181. current: index, //图片索引
  182. urls: previewUrls, //必须是http图片,本地图片无效
  183. longPressActions: ''
  184. })
  185. },
  186. conInput(e) {
  187. //备注文字字数限制
  188. let value = e.detail.value
  189. let len = parseInt(value.length)
  190. if (len > this.max) return
  191. this.min = len
  192. if (this.min == 200) {
  193. this.$util.msg('您输入的字数已达上限', 2000)
  194. }
  195. }
  196. },
  197. onShow() {}
  198. }
  199. </script>
  200. <style lang="scss">
  201. page {
  202. height: auto;
  203. background: #ffffff;
  204. }
  205. .remarks-content {
  206. width: 100%;
  207. height: auto;
  208. box-sizing: border-box;
  209. padding: 0 24rpx;
  210. .list-view-title {
  211. width: 100%;
  212. height: auto;
  213. margin-bottom: 16rpx;
  214. margin-top: 40rpx;
  215. .list-view-h1 {
  216. line-height: 40rpx;
  217. font-size: $font-size-28;
  218. color: #333333;
  219. text-align: left;
  220. text {
  221. color: #ff2a2a;
  222. }
  223. }
  224. .list-view-p {
  225. line-height: 30rpx;
  226. color: #fea785;
  227. font-size: $font-size-20;
  228. }
  229. }
  230. .remarks-textarea {
  231. width: 100%;
  232. height: 340rpx;
  233. padding: 16rpx;
  234. margin: 20rpx 0 0 0;
  235. border-radius: 6rpx;
  236. position: relative;
  237. border: 1px solid #b2b2b2;
  238. box-sizing: border-box;
  239. .textarea {
  240. width: 100%;
  241. height: 100%;
  242. line-height: 36rpx;
  243. font-size: $font-size-26;
  244. color: $text-color;
  245. z-index: 1;
  246. }
  247. .limit-text {
  248. position: absolute;
  249. right: 20rpx;
  250. bottom: 16rpx;
  251. line-height: 44rpx;
  252. font-size: $font-size-24;
  253. color: #b2b2b2;
  254. }
  255. }
  256. .list-view {
  257. width: 100%;
  258. height: 40rpx;
  259. margin-top: 20rpx;
  260. .list-view-file {
  261. width: 132rpx;
  262. height: 44rpx;
  263. line-height: 44rpx;
  264. font-size: $font-size-20;
  265. text-align: center;
  266. color: #ffffff;
  267. background-color: $color-system;
  268. border-radius: 8rpx;
  269. float: left;
  270. margin-top: 10rpx;
  271. }
  272. .list-view-text {
  273. width: 100%;
  274. float: left;
  275. .input {
  276. width: 560rpx;
  277. height: 44rpx;
  278. box-sizing: border-box;
  279. line-height: 44rpx;
  280. color: #333333;
  281. text-overflow: ellipsis;
  282. overflow: hidden;
  283. display: -webkit-box;
  284. -webkit-line-clamp: 1;
  285. line-clamp: 1;
  286. -webkit-box-orient: vertical;
  287. float: left;
  288. }
  289. .delbtn {
  290. width: 96rpx;
  291. height: 44rpx;
  292. border-radius: 8rpx;
  293. background-color: #fff2ec;
  294. font-size: $font-size-24;
  295. color: #e15616;
  296. line-height: 44rpx;
  297. text-align: center;
  298. float: left;
  299. }
  300. }
  301. }
  302. .list-view-upload {
  303. width: 100%;
  304. height: auto;
  305. .photo-item {
  306. display: inline-block;
  307. width: 112rpx;
  308. height: 112rpx;
  309. margin: 10rpx 0;
  310. margin-right: 25rpx;
  311. border-radius: 10rpx;
  312. border: 1px solid #f5f5f5;
  313. position: relative;
  314. float: left;
  315. &.add {
  316. width: 112rpx;
  317. height: 112rpx;
  318. border-color: #b2b2b2;
  319. text-align: center;
  320. line-height: 112rpx;
  321. margin-right: 0rpx;
  322. .icon-jiahao {
  323. font-size: $font-size-44;
  324. color: #b2b2b2;
  325. font-weight: bold;
  326. }
  327. }
  328. .icon-iconfontguanbi {
  329. width: 30rpx;
  330. height: 30rpx;
  331. border-radius: 50%;
  332. display: block;
  333. position: absolute;
  334. right: -10rpx;
  335. top: -10rpx;
  336. background: #f94b4b;
  337. text-align: center;
  338. line-height: 30rpx;
  339. color: #ffffff;
  340. font-size: $font-size-22;
  341. }
  342. image {
  343. width: 112rpx;
  344. height: 112rpx;
  345. border-radius: 10rpx;
  346. }
  347. }
  348. .photo-list {
  349. width: 100%;
  350. height: 116rpx;
  351. overflow: hidden;
  352. white-space: nowrap;
  353. display: flex;
  354. align-items: flex-start;
  355. }
  356. }
  357. }
  358. .remarks-btn {
  359. width: 100%;
  360. padding-top: 20rpx;
  361. position: fixed;
  362. bottom: 0;
  363. left: 0;
  364. background-color: #ffffff;
  365. .edit-button-canel {
  366. width: 100%;
  367. height: 88rpx;
  368. line-height: 88rpx;
  369. text-align: center;
  370. color: #e15616;
  371. font-size: $font-size-24;
  372. }
  373. .edit-button {
  374. width: 600rpx;
  375. height: 90rpx;
  376. background: $btn-confirm;
  377. line-height: 90rpx;
  378. text-align: center;
  379. color: #ffffff;
  380. font-size: $font-size-30;
  381. margin: 0 auto;
  382. border-radius: 45rpx;
  383. }
  384. }
  385. </style>