publish.vue 9.8 KB

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