publish.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. <template>
  2. <view>
  3. <my-bar title="发布活动" :transparent="transparent">
  4. <view slot="content" class="publish" @click="cropperSelect">
  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="禁止第一、含有竞争意识、夸大的宣传口号" maxlength="20"/>
  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" label="详细地址" prop="title">
  32. <u-input :border="false" placeholder="请详细写到门店编号" v-model="addressDetail" ></u-input>
  33. <view slot="right">
  34. <u-button @click="chooseAddress" size="mini">获取地址</u-button>
  35. </view>
  36. </u-form-item>
  37. <!-- <u-form-item v-if="form.address" prop="title" label="详细地址">
  38. <u-input v-model="addressDetail" placeholder="请输入详细地址" />
  39. </u-form-item> -->
  40. <u-form-item prop="supplyPrice" label-width="250" label="建议售卖价" left-icon="rmb-circle">
  41. <view class="flex justify-between">
  42. <u-input v-model="form.supplyPrice" placeholder="请输入建议售卖价" />
  43. <text style="color: #737373;">(%)</text>
  44. </view>
  45. </u-form-item>
  46. <u-form-item prop="labelIds" @click="showCheckBox" label-width="200" label="行业类目" left-icon="grid">
  47. <view @click="checkboxShow=true" class="flex justify-between ">
  48. <view class="u-flex u-flex-wrap">
  49. <view v-if="!checkboxList.some((i)=>{return i.checked==true})" style="color: #c0c4cc;">请选择
  50. </view>
  51. <view v-for="(item, index) in checkboxList" :key="index">
  52. <view v-if="item.checked" style="margin-right: 10rpx;">{{ item.name }}</view>
  53. </view>
  54. </view>
  55. <view>
  56. <u-icon name="arrow-right" color="#737373"></u-icon>
  57. </view>
  58. </view>
  59. </u-form-item>
  60. <u-form-item prop="beginTime" label="开始时间" left-icon="clock" label-width="180">
  61. <u-input type="select" @click="timeShow=true;timeType=1" v-model="form.beginTime"
  62. placeholder="请选择开始时间" />
  63. </u-form-item>
  64. <u-form-item prop="endTime" label="结束时间" left-icon="clock" label-width="180">
  65. <u-input type="select" @click="timeShow=true;timeType=2" v-model="form.endTime"
  66. placeholder="请选择结束时间" />
  67. </u-form-item>
  68. <u-form-item prop="subsidy" label-width="200" label="活动补贴" left-icon="coupon">
  69. <view class="flex justify-between">
  70. <u-input v-model="form.subsidy" placeholder="请输入折扣" />
  71. <text style="color: #737373;">(%)</text>
  72. </view>
  73. </u-form-item>
  74. <u-form-item prop="hundredPointValue" label-width="200" label="积分通兑" left-icon="coupon">
  75. <u-input v-model="form.hundredPointValue" placeholder="100 积分 = ? 元" />
  76. </u-form-item>
  77. </u-form>
  78. </view>
  79. <view class="form">
  80. <u-form label-position="top" label-width="160">
  81. <u-form-item label-width="200" label="活动详情" left-icon="coupon">
  82. <u-input type="area" height="150" v-model="form.detail" placeholder="不少于100字" />
  83. </u-form-item>
  84. </u-form>
  85. </view>
  86. <view class="center" style="margin: 50rpx 0;">
  87. <view @click="publish" class="flex flex-direction" style="width: 94%;">
  88. <view class="radius cu-btn btn-bg-color" style="height: 90rpx;">
  89. 提交审核
  90. </view>
  91. <view class="text-center margin-top-20">
  92. <text>提交即表示同意</text>
  93. <text style="color: #ff9447;" @click="protocol">《联兑通商家联营协议》</text>
  94. </view>
  95. </view>
  96. </view>
  97. <u-popup v-model="checkboxShow" mode="bottom" height="50%" border-radius="12">
  98. <view class="padding-30">
  99. <u-checkbox-group>
  100. <u-checkbox @change="checkboxChange" v-model="item.checked" v-for="(item, index) in checkboxList"
  101. :key="index" :name="index">
  102. {{ item.name }}
  103. </u-checkbox>
  104. </u-checkbox-group>
  105. </view>
  106. </u-popup>
  107. <u-picker v-model="timeShow" mode="time" @confirm="timeConfirm" :params="params"></u-picker>
  108. <u-picker mode="region" v-model="regionShow" @confirm="regionConfirm"></u-picker>
  109. </view>
  110. </template>
  111. <script>
  112. import myBar from "@/components/my-bar.vue"
  113. export default {
  114. components: {
  115. myBar
  116. },
  117. data() {
  118. return {
  119. transparent: 0,
  120. form: {
  121. pic: '',
  122. title: '',
  123. address: '',
  124. supplyPrice: '',
  125. labelIds: '',
  126. beginTime: '',
  127. endTime: '',
  128. detail: '',
  129. subsidy: '',
  130. hundredPointValue: '',
  131. sponsorType: 2,
  132. auditStatus: 0
  133. },
  134. addressDetail: '',
  135. checkboxShow: false,
  136. timeShow: false,
  137. timeType: 1,
  138. params: {
  139. year: true,
  140. month: true,
  141. day: true,
  142. hour: true,
  143. minute: true,
  144. second: true
  145. },
  146. checkboxList: [],
  147. regionShow: false,
  148. rules: {
  149. title: [{
  150. required: true,
  151. message: '请输入标题',
  152. trigger: ['blur', 'change']
  153. }],
  154. address: [{
  155. required: true,
  156. message: '请选择地区',
  157. trigger: 'change',
  158. }],
  159. beginTime: [{
  160. required: true,
  161. message: '请选择开始时间',
  162. trigger: 'change',
  163. }],
  164. endTime: [{
  165. required: true,
  166. message: '请选择结束时间',
  167. trigger: 'change',
  168. }],
  169. supplyPrice: [{
  170. required: true,
  171. message: '请输入建议售卖价',
  172. trigger: ['blur', 'change']
  173. }],
  174. subsidy: [{
  175. required: true,
  176. message: '请输入活动补贴',
  177. trigger: ['blur', 'change']
  178. }],
  179. hundredPointValue: [{
  180. required: true,
  181. message: '请输入积分通兑',
  182. trigger: ['blur', 'change']
  183. }],
  184. },
  185. //裁剪框宽度
  186. rectWidth:200,
  187. //裁剪框高度
  188. rectHeight:200
  189. }
  190. },
  191. onPageScroll(obj) {
  192. this.transparent = obj.scrollTop * 0.006;
  193. },
  194. onReady() {
  195. this.getElInfo()
  196. this.$refs.uForm.setRules(this.rules);
  197. },
  198. onLoad() {
  199. uni.$on('uAvatarCropper', (path) => {
  200. this.$api.uploadFile(path).then(res => {
  201. this.form.pic = res.data.link
  202. })
  203. })
  204. this.getShopLabelByMallId()
  205. },
  206. methods: {
  207. chooseAddress() {
  208. var _this = this
  209. uni.chooseLocation({
  210. success(res) {
  211. _this.addressDetail = res.address
  212. }
  213. })
  214. },
  215. async getElInfo() {
  216. let rectInfo = await this.$u.getRect('.publish');
  217. let scale = rectInfo.height / rectInfo.width
  218. this.rectWidth = parseInt(this.$u.sys().windowWidth - 20)
  219. this.rectHeight = parseInt(this.rectWidth * scale)
  220. },
  221. //图片裁剪
  222. cropperSelect() {
  223. let params = {
  224. destWidth: this.rectWidth,
  225. destHeight: this.rectHeight,
  226. rectWidth: this.rectWidth,
  227. rectHeight: this.rectHeight,
  228. fileType: 'jpg',
  229. }
  230. uni.navigateTo({
  231. url: "../image-cropper/image-cropper" + this.$u.queryParams(params)
  232. })
  233. },
  234. //显示多选框
  235. showCheckBox() {
  236. this.checkboxShow = true
  237. },
  238. //时间回调
  239. timeConfirm(e) {
  240. console.log(e);
  241. let date = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute + ':' + e.second
  242. if (this.timeType == 1) {
  243. this.form.beginTime = date
  244. } else {
  245. this.form.endTime = date
  246. }
  247. },
  248. //选择地址回调
  249. regionConfirm(e) {
  250. this.form.address = e.province.label + '-' + e.city.label + '-' + e.area.label;
  251. },
  252. //获取多选的标签
  253. getShopLabelByMallId() {
  254. let selectedShop = this.$cache.get('selectedShop')
  255. let labelIds = selectedShop.labelIds.split(",")
  256. let labelNames = selectedShop.labelNames.split(",")
  257. for (let i = 0; i < labelIds.length; i++) {
  258. let obj = {
  259. id: labelIds[i],
  260. name: labelNames[i],
  261. checked: false
  262. }
  263. this.checkboxList.push(obj)
  264. }
  265. // this.$api.mall.getShopLabelByMallId(this.vuex_mallId).then(res => {
  266. // res.data.forEach(item => {
  267. // item.checked = false
  268. // })
  269. // this.checkboxList = res.data
  270. // })
  271. },
  272. //多选确认
  273. checkboxChange(e) {
  274. this.checkboxList[e.name].checked = e.value
  275. this.$forceUpdate()
  276. },
  277. //确认发布
  278. publish() {
  279. this.$refs.uForm.validate(valid => {
  280. if (valid) {
  281. this.doPublish()
  282. } else {
  283. console.log('验证失败');
  284. }
  285. });
  286. },
  287. protocol(){
  288. uni.navigateTo({
  289. url: "/pages/webView/webView?url=" + this.$global.publishActivity
  290. })
  291. },
  292. doPublish() {
  293. if (!this.form.pic) {
  294. this.$u.toast('请上传封面图')
  295. return
  296. }
  297. let tmp = this.checkboxList.filter(item => item.checked == true).map(item => item.id)
  298. this.form.labelIds = tmp.join(',')
  299. if (!this.form.labelIds) {
  300. this.$u.toast('请选择行业类目')
  301. return
  302. }
  303. if (this.addressDetail) {
  304. this.form.address = this.form.address + ' ' + this.addressDetail
  305. }
  306. this.form.sponsorId = this.vuex_shopId
  307. this.$api.activity.publish(this.form).then(res => {
  308. if (res.success) {
  309. this.$dialog.showModal('发布成功,请耐心等待商场管理员审核', false).then(() => {
  310. this.$back()
  311. })
  312. }
  313. })
  314. }
  315. }
  316. }
  317. </script>
  318. <style lang="scss" scoped>
  319. .btn-bg-color{
  320. background-color: #FF9447;
  321. color: #FFFFFF;
  322. }
  323. .publish {
  324. overflow: hidden;
  325. border-radius: 10rpx;
  326. height: 380rpx;
  327. background-color: #f2f2f2;
  328. position: absolute;
  329. bottom: 20rpx;
  330. left: 0;
  331. right: 0;
  332. width: 92%;
  333. margin: 0 auto -120rpx;
  334. display: flex;
  335. justify-content: center;
  336. align-items: center;
  337. flex-direction: column;
  338. text {
  339. font-size: 26rpx;
  340. color: #797979;
  341. }
  342. }
  343. .clock {
  344. background-color: #FFFFFF;
  345. // height: 230rpx;
  346. height: 130rpx;
  347. padding-bottom: 20rpx;
  348. display: flex;
  349. flex-direction: column;
  350. justify-content: flex-end;
  351. align-items: center;
  352. .tips {
  353. margin-top: 10rpx;
  354. font-size: 24rpx;
  355. color: #FF9447;
  356. }
  357. }
  358. .form {
  359. margin-top: 15rpx;
  360. background-color: #FFFFFF;
  361. padding: 30rpx;
  362. border-radius: 10rpx;
  363. }
  364. </style>