editPage.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <div class="newRelease_com">
  3. <ul class="predetermineUl">
  4. <li class="predetermineLi2" style="border-bottom: none">
  5. <div class="liName">标题</div>
  6. <van-field
  7. :value="postData.businessName"
  8. autosize
  9. type="textarea"
  10. placeholder="请输入"
  11. class="myField"
  12. maxlength="50"
  13. show-word-limit
  14. @change="changeTitle"
  15. />
  16. </li>
  17. </ul>
  18. <ul class="predetermineUl">
  19. <li class="detailLi2" style="border-bottom: none">
  20. <span class="liName">
  21. 快捷选择
  22. </span>
  23. <div class="detailLi2Box">
  24. <div class="detailLi2BoxTop">
  25. <div class="checkItem" :class="checkedName===item.label?'checked':''" v-for="item in checkList" :key="item.id" @click="clickCheck(item)">{{item.label}}</div>
  26. </div>
  27. </div>
  28. </li>
  29. <li class="detailLi">
  30. <span class="liName">地址</span>
  31. <span >
  32. <input class="liInfo" placeholder="选择地址" v-model="postData.businessAddress" disabled @tap="showMap">
  33. <van-icon name="location" style="color: rgba(51, 51, 51, 0.90)"/>
  34. </span>
  35. </li>
  36. <li class="detailLi" style="border-bottom: none">
  37. <span class="liName">电话</span>
  38. <span >
  39. <input class="liInfo" placeholder="请填写" v-model="postData.businessPhone">
  40. </span>
  41. </li>
  42. </ul>
  43. <ul class="predetermineUl">
  44. <li class="detailLi2">
  45. <div class="titleBox" style="margin-bottom: 24rpx">
  46. <span class="liName">简介</span>
  47. <span class="tips">(支持图片上传限20M内,最多1张)</span>
  48. </div>
  49. <van-uploader
  50. :max-count="1"
  51. @delete="deleteRYXXZP"
  52. :file-list="fileList"
  53. @after-read="uploadRYXXZP"
  54. :show-upload="true"
  55. />
  56. <van-field
  57. :value="postData.introduction"
  58. autosize
  59. type="textarea"
  60. placeholder="请输入"
  61. class="myField"
  62. maxlength="2000"
  63. show-word-limit
  64. @change="changeIntro"
  65. />
  66. </li>
  67. </ul>
  68. <div class="buttonBox">
  69. <button class="btn zcBtn" @tap="addSurr('unpublished')">暂存</button>
  70. <button class="btn tjBtn" @tap="addSurr('published')">发布</button>
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. import dayjs from "dayjs";
  76. import { getByCodes,peripheryEdit,getUserLocalStorageInfo, peripheryGetById} from "@/js_sdk/http";
  77. export default {
  78. name: "editPage",
  79. data(){
  80. return{
  81. dc_key: ['periphery_type'],
  82. fileList:[],
  83. checkList:[],
  84. postData:{
  85. createdBy:getUserLocalStorageInfo().userId,
  86. status:'',
  87. businessName:'',
  88. type:'',
  89. businessAddress:'',
  90. longitude:'',
  91. latitude:'',
  92. businessPhone:'',
  93. fileUrl:'',
  94. introduction:'',
  95. releaseType:'periphery'
  96. },
  97. checkedName:'干洗',
  98. }
  99. },
  100. onLoad(options){
  101. console.log(options.id)
  102. this.getByCodes()
  103. peripheryGetById({id:options.id}).then(res=>{
  104. if (res.code==200){
  105. this.postData = res.data
  106. const typeObj = this.checkList.find(e=>{
  107. return res.data.type === e.value
  108. })
  109. this.checkedName = typeObj.label
  110. this.fileList = [{
  111. imgUrl: "/FileController/download/" + res.data.fileUrl,
  112. id: res.data.fileUrl,
  113. url:
  114. this.$constant.BASE_URI +
  115. "/FileController/download/" +
  116. res.data.fileUrl,
  117. isImage: true,
  118. }]
  119. console.log(this.fileList)
  120. }
  121. console.log(res)
  122. })
  123. },
  124. created(){
  125. },
  126. methods:{
  127. changeTitle(e){
  128. this.postData.businessName = e.detail
  129. },
  130. changeIntro(e){
  131. this.postData.introduction = e.detail
  132. },
  133. async getByCodes() {
  134. let data = await getByCodes(JSON.stringify(this.dc_key));
  135. this.dic_SelectList = this.$common.handleDicList(data);
  136. this.checkList = this.dic_SelectList.periphery_type
  137. console.log('checkList',this.checkList)
  138. },
  139. clickCheck(item){
  140. // console.log(item)
  141. this.checkedName = item.label
  142. this.postData.type = item.value
  143. },
  144. showMap(){
  145. const _this = this
  146. uni.chooseLocation({
  147. success: function (res) {
  148. console.log('选择的位置:', res.name);
  149. _this.postData.businessAddress = res.name
  150. console.log('纬度:' + res.latitude + ',经度:' + res.longitude);
  151. _this.postData.latitude = res.latitude
  152. _this.postData.longitude = res.longitude
  153. // 其他业务逻辑
  154. },
  155. fail: function (error) {
  156. console.error('Choose location failed: ' + JSON.stringify(error));
  157. },
  158. complete: function () {
  159. console.log('chooseLocation operation is complete');
  160. }
  161. });
  162. },
  163. addSurr(e){
  164. const dayjs = require('dayjs')
  165. const fileArr = []
  166. this.fileList.forEach(file=>{
  167. fileArr.push(file.id)
  168. })
  169. this.postData.fileUrl = fileArr.toString()
  170. this.postData.status = e
  171. let toastMsg = ''
  172. if (e==='published'){
  173. this.postData.publisherUserId = getUserLocalStorageInfo().userId
  174. this.postData.releaseTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
  175. toastMsg = '发布成功'
  176. }else{
  177. toastMsg = '暂存成功'
  178. }
  179. // console.log(this.postData)
  180. peripheryEdit(this.postData).then(res=>{
  181. if (res.code=='200'){
  182. uni.showToast({
  183. title: toastMsg,
  184. duration: 500
  185. });
  186. uni.navigateBack()
  187. }else{
  188. uni.showToast({
  189. title: res.msg,
  190. duration: 500
  191. });
  192. }
  193. })
  194. },
  195. onChange(e){
  196. },
  197. deleteRYXXZP(event) {
  198. this.fileList.splice(event.detail.index, 1);
  199. this.$forceUpdate();
  200. },
  201. uploadRYXXZP(event) {
  202. console.log(event)
  203. let that = this;
  204. const { file } = event.detail;
  205. uni.uploadFile({
  206. url: that.$constant.BASE_URI + "/wx/fileController/upload",
  207. filePath: file.url,
  208. name: "file",
  209. formData: { user: "test" },
  210. success(res) {
  211. // 上传完成需要更新 fileList
  212. let data = JSON.parse(res.data);
  213. console.log('data',data)
  214. that.fileList.push({
  215. imgUrl: "/FileController/download/" + data.data[0],
  216. id: data.data[0],
  217. url:
  218. that.$constant.BASE_URI +
  219. "/FileController/download/" +
  220. data.data[0],
  221. isImage: true,
  222. });
  223. },
  224. fail(res) {},
  225. });
  226. },
  227. }
  228. }
  229. </script>
  230. <style lang="scss">
  231. .newRelease_com{
  232. .predetermineUl{
  233. margin: 24rpx 0;
  234. background: white;
  235. box-sizing: border-box;
  236. padding: 0 32rpx;
  237. .predetermineLi{
  238. padding: 32rpx 0;
  239. border-bottom: 1px solid rgba(230, 230, 230, 1);
  240. display: flex;
  241. justify-content: space-between;
  242. }
  243. .predetermineLi2{
  244. padding: 32rpx 0;
  245. border-bottom: 1px solid rgba(230, 230, 230, 1);
  246. display: flex;
  247. flex-direction: column;
  248. }
  249. .van-cell {
  250. background: #F5F7FA !important;
  251. border-radius: 8rpx;
  252. font-size: 28rpx;
  253. margin-top: 16rpx;
  254. }
  255. .liName{
  256. color: rgba(51, 51, 51, 1);
  257. font-size: 32rpx;
  258. }
  259. .liIpt{
  260. color: rgba(102, 102, 102, 1);
  261. font-size: 32rpx;
  262. text-align: right;
  263. }
  264. .detailLi{
  265. display: flex;
  266. justify-content: space-between;
  267. align-items: center;
  268. padding: 32rpx 0;
  269. border-bottom: 2rpx solid #E6E6E6;
  270. .liInfo{
  271. display: inline-block;
  272. text-align: right;
  273. min-width: 528rpx;
  274. max-width: 528rpx;
  275. color: rgba(102, 102, 102, 1);
  276. font-size: 32rpx;
  277. line-height: 38rpx;
  278. .radio{
  279. margin-left: 64rpx;
  280. }
  281. }
  282. }
  283. .detailLi2{
  284. display: flex;
  285. flex-direction: column;
  286. padding: 32rpx 0;
  287. border-bottom: 2rpx solid #E6E6E6;
  288. .detailLi2BoxTop{
  289. display: flex;
  290. flex-wrap: wrap;
  291. justify-content: space-between;
  292. margin: 12rpx 0;
  293. .checkItem{
  294. width: 128rpx;
  295. height: 64rpx;
  296. font-size: 28rpx;
  297. color: #666666;
  298. display: flex;
  299. align-items: center;
  300. justify-content: center;
  301. background: #F5F7FA;
  302. border-radius: 8rpx;
  303. margin: 12rpx 0;
  304. }
  305. .checked{
  306. background: #0365F9;
  307. color: white;
  308. }
  309. }
  310. }
  311. }
  312. .titleBox{
  313. display: flex;
  314. align-items: center;
  315. .titleName{
  316. color: rgba(24, 23, 42, 1);
  317. font-size: 32rpx;
  318. font-weight: 600;
  319. margin-right: 16rpx;
  320. }
  321. .tips{
  322. font-size: 28rpx;
  323. color: rgba(179, 179, 179, 1);
  324. }
  325. }
  326. .buttonBox{
  327. display: flex;
  328. justify-content: center;
  329. .btn{
  330. width: 240rpx;
  331. height: 80rpx;
  332. display: flex;
  333. border-radius: 8rpx;
  334. align-items: center;
  335. justify-content: center;
  336. margin: 48rpx 16rpx 150rpx 16rpx;
  337. color: white;
  338. letter-spacing: 2rpx;
  339. text-indent: 2rpx;
  340. }
  341. .zcBtn{
  342. background: #FE8643;
  343. }
  344. .tjBtn{
  345. background: #0365F9;
  346. }
  347. }
  348. }
  349. </style>