publish.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view>
  3. <my-bar title="发布活动" :transparent="transparent">
  4. <view slot="content" class="publish" @click="chooseImage">
  5. <block v-if="!form.pic">
  6. <u-icon name="photo" size="100" color="#cecece"></u-icon>
  7. <text>上传活动封面</text>
  8. </block>
  9. <image :src="form.pic" 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 label="地区" prop="address" left-icon="map">
  28. <u-input type="select" :select-open="regionShow" v-model="form.address" placeholder="请选择地区"
  29. @click="regionShow = true"></u-input>
  30. </u-form-item>
  31. <u-form-item v-if="form.address" prop="title" label="详细地址">
  32. <u-input v-model="addressDetail" placeholder="请输入详细地址" />
  33. </u-form-item>
  34. <u-form-item prop="supplyPrice" label-width="250" label="建议供应价" left-icon="rmb-circle">
  35. <view class="flex justify-between">
  36. <u-input v-model="form.supplyPrice" placeholder="请输入建议供应价" />
  37. <text style="color: #737373;">(%)</text>
  38. </view>
  39. </u-form-item>
  40. <u-form-item prop="labelIds" @click="showCheckBox" label-width="200" label="行业类目" left-icon="grid">
  41. <view @click="checkboxShow=true" class="flex justify-between ">
  42. <view @click.stop="" style="display: flex;flex-direction: column;justify-content: center;">
  43. <u-checkbox-group>
  44. <u-checkbox @change="checkboxChange" v-model="item.checked" v-if="index<=1"
  45. v-for="(item, index) in checkboxList" :key="index" :name="index">
  46. {{ item.name }}
  47. </u-checkbox>
  48. </u-checkbox-group>
  49. </view>
  50. <view>
  51. <u-icon name="arrow-right" color="#737373"></u-icon>
  52. </view>
  53. </view>
  54. </u-form-item>
  55. <u-form-item prop="beginTime" label="开始时间" left-icon="clock" label-width="180">
  56. <u-input type="select" @click="timeShow=true;timeType=1" v-model="form.beginTime"
  57. placeholder="请选择开始时间" />
  58. </u-form-item>
  59. <u-form-item prop="endTime" label="结束时间" left-icon="clock" label-width="180">
  60. <u-input type="select" @click="timeShow=true;timeType=2" v-model="form.endTime"
  61. placeholder="请选择结束时间" />
  62. </u-form-item>
  63. <u-form-item prop="subsidy" label-width="200" label="活动补贴" left-icon="coupon">
  64. <view class="flex justify-between">
  65. <u-input v-model="form.subsidy" placeholder="请输入折扣" />
  66. <text style="color: #737373;">(%)</text>
  67. </view>
  68. </u-form-item>
  69. <u-form-item prop="hundredPointValue" label-width="200" label="积分通兑" left-icon="coupon">
  70. <u-input v-model="form.hundredPointValue" placeholder="100 积分 = ? 元" />
  71. </u-form-item>
  72. </u-form>
  73. </view>
  74. <view class="form">
  75. <u-form label-position="top" label-width="160">
  76. <u-form-item label-width="200" label="活动详情" left-icon="coupon">
  77. <u-input type="area" height="150" v-model="form.detail" placeholder="不少于100字" />
  78. </u-form-item>
  79. </u-form>
  80. </view>
  81. <view class="center" style="margin: 50rpx 0;">
  82. <view @click="publish" class="flex flex-direction" style="width: 94%;">
  83. <view class="radius cu-btn btn-bg-color" style="height: 90rpx;">
  84. 提交审核
  85. </view>
  86. <view class="text-center margin-top-20">
  87. <text>提交即表示同意</text>
  88. <text class="btn-color">《商家活动工具活动发布规则》</text>
  89. </view>
  90. </view>
  91. </view>
  92. <u-popup v-model="checkboxShow" mode="bottom" height="50%" border-radius="12">
  93. <view class="padding-30">
  94. <u-checkbox-group>
  95. <u-checkbox @change="checkboxChange" v-model="item.checked" v-for="(item, index) in checkboxList"
  96. :key="index" :name="index">
  97. {{ item.name }}
  98. </u-checkbox>
  99. </u-checkbox-group>
  100. </view>
  101. </u-popup>
  102. <u-picker v-model="timeShow" mode="time" @confirm="timeConfirm" :params="params"></u-picker>
  103. <u-picker mode="region" v-model="regionShow" @confirm="regionConfirm"></u-picker>
  104. </view>
  105. </template>
  106. <script>
  107. import myBar from "@/components/my-bar.vue"
  108. export default {
  109. components: {
  110. myBar
  111. },
  112. data() {
  113. return {
  114. transparent: 0,
  115. form: {
  116. pic: '',
  117. title: '',
  118. address: '',
  119. supplyPrice: '',
  120. labelIds: '',
  121. beginTime: '',
  122. endTime: '',
  123. detail: '',
  124. subsidy: '',
  125. hundredPointValue: '',
  126. sponsorType:1,
  127. auditStatus:0
  128. },
  129. addressDetail: '',
  130. checkboxShow: false,
  131. timeShow: false,
  132. timeType: 1,
  133. params: {
  134. year: true,
  135. month: true,
  136. day: true,
  137. hour: true,
  138. minute: true,
  139. second: true
  140. },
  141. checkboxList: [],
  142. regionShow: false,
  143. rules: {
  144. title: [{
  145. required: true,
  146. message: '请输入标题',
  147. trigger: ['blur', 'change']
  148. }],
  149. address: [{
  150. required: true,
  151. message: '请选择地区',
  152. trigger: 'change',
  153. }],
  154. beginTime: [{
  155. required: true,
  156. message: '请选择开始时间',
  157. trigger: 'change',
  158. }],
  159. endTime: [{
  160. required: true,
  161. message: '请选择结束时间',
  162. trigger: 'change',
  163. }],
  164. supplyPrice: [{
  165. required: true,
  166. message: '请输入建议供应价',
  167. trigger: ['blur', 'change']
  168. }],
  169. subsidy: [{
  170. required: true,
  171. message: '请输入活动补贴',
  172. trigger: ['blur', 'change']
  173. }],
  174. hundredPointValue: [{
  175. required: true,
  176. message: '请输入积分通兑',
  177. trigger: ['blur', 'change']
  178. }],
  179. }
  180. }
  181. },
  182. onPageScroll(obj) {
  183. this.transparent = obj.scrollTop * 0.006;
  184. },
  185. onReady() {
  186. this.$refs.uForm.setRules(this.rules);
  187. },
  188. onLoad() {
  189. this.getShopLabelByMallId()
  190. },
  191. methods: {
  192. //显示多选框
  193. showCheckBox() {
  194. this.checkboxShow = true
  195. },
  196. //时间回调
  197. timeConfirm(e) {
  198. console.log(e);
  199. let date = e.year + '-' + e.month + '-' + e.day+ ' ' + e.hour+ ':' + e.minute+ ':' + e.second
  200. if (this.timeType == 1) {
  201. this.form.beginTime = date
  202. } else {
  203. this.form.endTime = date
  204. }
  205. },
  206. //选择地址回调
  207. regionConfirm(e) {
  208. this.form.address = e.province.label + '-' + e.city.label + '-' + e.area.label;
  209. },
  210. //获取多选的标签
  211. getShopLabelByMallId() {
  212. this.$api.mall.getShopLabelByMallId(this.vuex_mallId).then(res => {
  213. res.data.forEach(item => {
  214. item.checked = false
  215. })
  216. this.checkboxList = res.data
  217. })
  218. },
  219. //多选确认
  220. checkboxChange(e) {
  221. this.checkboxList[e.name].checked = e.value
  222. this.$forceUpdate()
  223. },
  224. //选择图片
  225. async chooseImage() {
  226. let res = await this.$mpi.chooseImage()
  227. this.$api.uploadFile(res[0]).then(res => {
  228. this.form.pic = res.data.link
  229. })
  230. },
  231. //确认发布
  232. publish() {
  233. this.$refs.uForm.validate(valid => {
  234. if (valid) {
  235. this.doPublish()
  236. } else {
  237. console.log('验证失败');
  238. }
  239. });
  240. },
  241. doPublish() {
  242. if (!this.form.pic) {
  243. this.$u.toast('请上传封面图')
  244. return
  245. }
  246. let tmp = this.checkboxList.filter(item => item.checked == true).map(item => item.id)
  247. this.form.labelIds = tmp.join(',')
  248. if (!this.form.labelIds) {
  249. this.$u.toast('请选择行业类目')
  250. return
  251. }
  252. if (this.addressDetail) {
  253. this.form.address = this.form.address + ' ' + this.addressDetail
  254. }
  255. this.form.sponsorId=this.vuex_mallId
  256. this.$api.activity.publish(this.form).then(res=>{
  257. if (res.success) {
  258. this.$dialog.showModal('发布成功,请耐心等待平台审核',false).then(()=>{
  259. this.$back()
  260. })
  261. }
  262. })
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="scss" scoped>
  268. .publish {
  269. overflow: hidden;
  270. border-radius: 10rpx;
  271. height: 380rpx;
  272. background-color: #f2f2f2;
  273. position: absolute;
  274. bottom: 20rpx;
  275. left: 0;
  276. right: 0;
  277. width: 92%;
  278. margin: 0 auto -120rpx;
  279. display: flex;
  280. justify-content: center;
  281. align-items: center;
  282. flex-direction: column;
  283. text {
  284. font-size: 26rpx;
  285. color: #797979;
  286. }
  287. }
  288. .clock {
  289. background-color: #FFFFFF;
  290. // height: 230rpx;
  291. height: 130rpx;
  292. padding-bottom: 20rpx;
  293. display: flex;
  294. flex-direction: column;
  295. justify-content: flex-end;
  296. align-items: center;
  297. .tips {
  298. margin-top: 10rpx;
  299. font-size: 24rpx;
  300. color: #FF9447;
  301. }
  302. }
  303. .form {
  304. margin-top: 15rpx;
  305. background-color: #FFFFFF;
  306. padding: 30rpx;
  307. border-radius: 10rpx;
  308. }
  309. </style>