publish-old.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <view>
  3. <my-bar title="发布活动" :transparent="transparent">
  4. <view slot="content" class="publish" @click="cropperSelect()">
  5. <block v-if="!form.poster">
  6. <u-icon name="photo" size="100" color="#cecece"></u-icon>
  7. <text>上传活动封面</text>
  8. </block>
  9. <image :src="form.poster" style="height: 380rpx;" v-else mode="heightFix"></image>
  10. </view>
  11. </my-bar>
  12. <view class="clock">
  13. <!-- <view class="cu-btn round sm" style="background-color: #dcdcdc;">
  14. <u-icon name="clock"></u-icon>
  15. <text class="margin-left-10">设置响应倒计时</text>
  16. </view>
  17. <view class="tips">
  18. <text>*</text>
  19. <text>如未在限定时间内响应,系统默认自动推送给旗下商户。</text>
  20. </view> -->
  21. </view>
  22. <view class="form">
  23. <u-form :model="form" :error-type="['message']" :rules="rules" ref="uForm" label-width="140">
  24. <u-form-item prop="title" label="标题" left-icon="bookmark">
  25. <u-input v-model="form.title" placeholder="请输入标题" />
  26. </u-form-item>
  27. <u-form-item prop="supplyPrice" label-width="200" label="活动折扣" left-icon="rmb-circle">
  28. <u-input v-model="form.discount" placeholder="请输入活动折扣(如:输入9,表示9折)" />
  29. </u-form-item>
  30. <u-form-item @click="showCheckBox" label-width="200" label="行业类目" left-icon="grid">
  31. <view @click="checkboxShow=true" class="flex justify-between ">
  32. <view class="u-flex u-flex-wrap">
  33. <view v-if="!checkboxList.some((i)=>{return i.checked==true})" style="color: #c0c4cc;">请选择
  34. </view>
  35. <view v-for="(item, index) in checkboxList" :key="index">
  36. <view v-if="item.checked" style="margin-right: 10rpx;">{{ item.dictKey }}</view>
  37. </view>
  38. </view>
  39. <view>
  40. <u-icon name="arrow-right" color="#737373"></u-icon>
  41. </view>
  42. </view>
  43. </u-form-item>
  44. <u-form-item prop="beginTime" label="开始时间" left-icon="clock" label-width="180">
  45. <u-input type="select" @click="timeShow=true;timeType=1" v-model="form.beginTime"
  46. placeholder="请选择开始时间" />
  47. </u-form-item>
  48. <u-form-item prop="endTime" label="结束时间" left-icon="clock" label-width="180">
  49. <u-input type="select" @click="timeShow=true;timeType=2" v-model="form.endTime"
  50. placeholder="请选择结束时间" />
  51. </u-form-item>
  52. </u-form>
  53. </view>
  54. <view class="form">
  55. <u-form label-position="top" label-width="160">
  56. <u-form-item label-width="200" label="活动详情" left-icon="coupon">
  57. <u-input type="area" height="200" v-model="form.intro" placeholder="请输入活动详情" />
  58. </u-form-item>
  59. </u-form>
  60. </view>
  61. <view class="center" style="margin: 50rpx 0;">
  62. <view @click="publish" class="flex flex-direction" style="width: 94%;">
  63. <view class="radius cu-btn btn-bg-color" style="height: 90rpx;">
  64. 提交审核
  65. </view>
  66. <view class="text-center margin-top-20">
  67. <text>提交即表示同意</text>
  68. <text class="btn-color" @click="protocol">《联兑通商家联营协议》</text>
  69. </view>
  70. </view>
  71. </view>
  72. <u-popup v-model="checkboxShow" mode="bottom" height="50%" border-radius="12">
  73. <view class="padding-30">
  74. <u-checkbox-group>
  75. <u-checkbox @change="checkboxChange" v-model="item.checked" v-for="(item, index) in checkboxList"
  76. :key="index" :name="index">
  77. {{ item.dictKey }}
  78. </u-checkbox>
  79. </u-checkbox-group>
  80. </view>
  81. </u-popup>
  82. <cropper ref="cropper" selWidth="800rpx" selHeight="400rpx" @upload="cropperCondirm" :avatarSrc="form.pic"
  83. avatarStyle="width:100vw;height:100vw;">
  84. </cropper>
  85. <u-picker confirm-color="#EF9944" v-model="timeShow" mode="time" @confirm="timeConfirm" :params="params">
  86. </u-picker>
  87. </view>
  88. </template>
  89. <script>
  90. import myBar from "@/components/my-bar.vue"
  91. export default {
  92. components: {
  93. myBar
  94. },
  95. data() {
  96. return {
  97. transparent: 0,
  98. form: {
  99. poster: '',
  100. title: '',
  101. discount: '',
  102. labelKey: '',
  103. beginTime: '',
  104. endTime: '',
  105. intro: '',
  106. launchType: this.$global.SHOP,
  107. launchId: this.vuex_shopId,
  108. mallId: this.vuex_mallId,
  109. labelParentIds: '',
  110. labelJson: '',
  111. labelKey: '',
  112. labelValue: '',
  113. processDefinitionId: ''
  114. },
  115. checkboxShow: false,
  116. timeShow: false,
  117. timeType: 1,
  118. params: {
  119. year: true,
  120. month: true,
  121. day: true,
  122. hour: true,
  123. minute: true,
  124. second: true
  125. },
  126. checkboxList: [],
  127. rules: {
  128. title: [{
  129. required: true,
  130. message: '请输入标题',
  131. trigger: ['blur', 'change']
  132. }],
  133. beginTime: [{
  134. required: true,
  135. message: '请选择开始时间',
  136. trigger: 'change',
  137. }],
  138. endTime: [{
  139. required: true,
  140. message: '请选择结束时间',
  141. trigger: 'change',
  142. }],
  143. discount: [{
  144. required: true,
  145. message: '请输入建议供应价',
  146. trigger: ['blur', 'change']
  147. }],
  148. //裁剪框宽度
  149. rectWidth: 200,
  150. //裁剪框高度
  151. rectHeight: 200
  152. }
  153. }
  154. },
  155. onPageScroll(obj) {
  156. this.transparent = obj.scrollTop * 0.006;
  157. },
  158. onReady() {
  159. this.getElInfo()
  160. this.$refs.uForm.setRules(this.rules);
  161. },
  162. onLoad() {
  163. uni.$on('uAvatarCropper', (path) => {
  164. this.$api.uploadFile(path).then(res => {
  165. this.form.poster = res.data.link
  166. })
  167. })
  168. this.form.launchId = this.vuex_shopId
  169. this.form.mallId = this.vuex_mallId
  170. this.getTagSelect()
  171. this.getProcessDefinitionId()
  172. },
  173. methods: {
  174. //获取发布活动流程id
  175. getProcessDefinitionId() {
  176. let params = {
  177. category: 'flow_4',
  178. mode: 1
  179. }
  180. this.$api.flow.getProcessDefinitionId(params).then(res => {
  181. this.form.processDefinitionId = res.data.records[0].id
  182. if (this.$isEmpty(this.form.processDefinitionId)) {
  183. this.$dialog.showModalAndBack("系统错误,获取流程主键失败")
  184. return
  185. }
  186. })
  187. },
  188. protocol() {
  189. uni.navigateTo({
  190. url: "/pages/webView/webView?url=" + this.$global.publishActivity
  191. })
  192. },
  193. async getElInfo() {
  194. let rectInfo = await this.$u.getRect('.publish');
  195. let scale = rectInfo.height / rectInfo.width
  196. this.rectWidth = parseInt(this.$u.sys().windowWidth - 20)
  197. this.rectHeight = parseInt(this.rectWidth * scale)
  198. },
  199. //图片裁剪
  200. cropperSelect() {
  201. let params = {
  202. destWidth: this.rectWidth,
  203. destHeight: this.rectHeight,
  204. rectWidth: this.rectWidth,
  205. rectHeight: this.rectHeight,
  206. fileType: 'jpg',
  207. }
  208. console.log(params);
  209. uni.navigateTo({
  210. url: "../image-cropper/image-cropper" + this.$u.queryParams(params)
  211. })
  212. },
  213. //显示多选框
  214. showCheckBox() {
  215. this.checkboxShow = true
  216. },
  217. //时间回调
  218. timeConfirm(e) {
  219. console.log(e);
  220. let date = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second
  221. if (this.timeType == 1) {
  222. this.form.beginTime = date
  223. } else {
  224. this.form.endTime = date
  225. }
  226. },
  227. //获取多选的标签
  228. getTagSelect() {
  229. let params = {
  230. current: 1,
  231. size: 50,
  232. code: 'business_label',
  233. parentId: '1430415753412112385'
  234. }
  235. this.$api.dict.getTagSelect(params).then(res => {
  236. res.data.forEach(item => {
  237. item.checked = false
  238. })
  239. this.checkboxList = res.data
  240. })
  241. },
  242. //多选确认
  243. checkboxChange(e) {
  244. this.checkboxList[e.name].checked = e.value
  245. this.$forceUpdate()
  246. },
  247. //确认发布
  248. publish() {
  249. this.$refs.uForm.validate(valid => {
  250. if (valid) {
  251. this.doPublish()
  252. } else {
  253. console.log('验证失败');
  254. }
  255. });
  256. },
  257. doPublish() {
  258. if (!this.form.poster) {
  259. this.$u.toast('请上传封面图')
  260. return
  261. }
  262. let tmpList = this.checkboxList.filter(item => item.checked == true)
  263. let labelParentIds = new Set(tmpList.map(item => item.parentId))
  264. this.form.labelParentIds = Array.from(new Set(tmpList.map(item => item.parentId))).join(',')
  265. this.form.labelJson = JSON.stringify(tmpList)
  266. this.form.labelKey = tmpList.map(item => item.dictKey).join(',')
  267. this.form.labelValue = tmpList.map(item => item.id).join(',')
  268. if (!this.form.labelValue) {
  269. this.$u.toast('请选择行业类目')
  270. return
  271. }
  272. let params = this.$u.deepClone(this.form)
  273. params.discount = this.$digital.floatMul(this.form.discount, 0.1)
  274. this.$api.activity.publish(params).then(res => {
  275. if (res.success) {
  276. let params = {
  277. path: '/pages/index/index',
  278. title: '活动发布成功,请耐心等待审核'
  279. }
  280. uni.redirectTo({
  281. url: '/pages/login/submit-success?params=' + JSON.stringify(params)
  282. })
  283. }
  284. })
  285. }
  286. }
  287. }
  288. </script>
  289. <style lang="scss" scoped>
  290. .publish {
  291. overflow: hidden;
  292. border-radius: 10rpx;
  293. height: 380rpx;
  294. background-color: #f2f2f2;
  295. position: absolute;
  296. bottom: 20rpx;
  297. left: 0;
  298. right: 0;
  299. width: 92%;
  300. margin: 0 auto -120rpx;
  301. display: flex;
  302. justify-content: center;
  303. align-items: center;
  304. flex-direction: column;
  305. text {
  306. font-size: 26rpx;
  307. color: #797979;
  308. }
  309. }
  310. .clock {
  311. background-color: #FFFFFF;
  312. // height: 230rpx;
  313. height: 130rpx;
  314. padding-bottom: 20rpx;
  315. display: flex;
  316. flex-direction: column;
  317. justify-content: flex-end;
  318. align-items: center;
  319. .tips {
  320. margin-top: 10rpx;
  321. font-size: 24rpx;
  322. color: #FF9447;
  323. }
  324. }
  325. .form {
  326. margin-top: 15rpx;
  327. background-color: #FFFFFF;
  328. padding: 30rpx;
  329. border-radius: 10rpx;
  330. }
  331. </style>