publish.vue 9.1 KB

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