publish.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="margin-20">
  3. <view @click="cropperSelect()" v-if="$isEmpty(form.poster)" class="cover center"
  4. style="flex-direction: column;">
  5. <text class="cuIcon-roundaddfill text-base" style="font-size: 70rpx;"></text>
  6. <text style="margin-top: 10rpx;">请上传活动封面</text>
  7. </view>
  8. <view @click="cropperSelect()" v-else class="center">
  9. <image class="shadow" mode="aspectFill" style="height: 340rpx;width: 95%;border-radius: 12rpx;" :src="form.poster">
  10. </image>
  11. </view>
  12. <view class="content">
  13. <view class="margin-top-10">
  14. <text class="cuIcon-titles" style="color: #EF9944;"></text>
  15. <text class="title">活动主题</text>
  16. <view class="solid-bottom" style="padding: 20rpx 0;">
  17. <u-input v-model="form.title" placeholder-style="color: #d8d8d8;" placeholder="请输入活动主题" />
  18. </view>
  19. </view>
  20. <view class="margin-top-30">
  21. <view class="title margin-left-10">
  22. <text>活动折扣</text>
  23. <text class="text-sm text-base margin-left-10" style="font-weight: 400;">({{desc}})</text>
  24. </view>
  25. <view class="solid-bottom" style="padding:60rpx 40rpx">
  26. <u-slider height="10" v-model="value" active-color="#EF9944" :use-slot="true">
  27. <view class="">
  28. <view class="">
  29. <view class="badge-button" style="display: flex;">
  30. <text>{{value / 10}}</text>
  31. </view>
  32. </view>
  33. </view>
  34. </u-slider>
  35. </view>
  36. </view>
  37. <view class="margin-top-30">
  38. <text class="title margin-left-10">活动时间</text>
  39. <view class="solid-bottom flex" style="padding: 20rpx 0;">
  40. <u-input input-align="center" placeholder-style="color: #d8d8d8;" disabled
  41. @click="timeShow=true;timeType=1" v-model="form.beginTime" placeholder="开始时间" />
  42. <view class="center" style="padding: 0 50rpx;">至</view>
  43. <u-input input-align="center" placeholder-style="color: #d8d8d8;" disabled
  44. @click="timeShow=true;timeType=2" v-model="form.endTime" placeholder="结束时间" />
  45. </view>
  46. </view>
  47. <view class="margin-top-30">
  48. <text class="title margin-left-10">活动详情</text>
  49. <view class="" style="padding: 20rpx 0;">
  50. <u-input :custom-style="{'lineHeight':'46rpx'}" maxlength="150" :clearable="false"
  51. input-align="left" :border="true" border-color="#f4f4f4" placeholder-style="color: #d8d8d8;"
  52. height="400" type="textarea" placeholder="请输入活动详情" v-model="form.intro" />
  53. <view class="text-right text-sm text-gray padding-right-20" style="margin-top: -40rpx;">
  54. <text>{{form.intro.length}}/150</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. <view class="center flex-direction" style="margin: 60rpx;">
  60. <view class="text-center margin-bottom-20 text-gray text-sm">
  61. <text>提交即表示同意</text>
  62. <text class="btn-color" @click="protocol">《联兑通商家联营协议》</text>
  63. </view>
  64. <view @click="publish" class="cu-btn flex text-lg btn-bg-color radius"
  65. style="padding: 42rpx 0;width: 100%;">
  66. 提交审核
  67. </view>
  68. </view>
  69. <toast ref="toast"></toast>
  70. <u-picker confirm-color="#EF9944" v-model="timeShow" mode="time" @confirm="timeConfirm" :params="params">
  71. </u-picker>
  72. </view>
  73. </template>
  74. <script>
  75. export default {
  76. components: {},
  77. data() {
  78. return {
  79. desc: '',
  80. value: 90,
  81. form: {
  82. poster: '',
  83. title: '',
  84. discount: '',
  85. beginTime: '',
  86. endTime: '',
  87. intro: '',
  88. launchType: this.$global.SHOP,
  89. launchId: this.vuex_shopId,
  90. mallId: this.vuex_mallId,
  91. processDefinitionId: ''
  92. },
  93. //发布时间
  94. timeShow: false,
  95. timeType: 0,
  96. params: {
  97. year: true,
  98. month: true,
  99. day: true,
  100. hour: false,
  101. minute: false,
  102. second: false
  103. },
  104. //裁剪框宽度
  105. rectWidth: 200,
  106. //裁剪框高度
  107. rectHeight: 200
  108. };
  109. },
  110. onLoad() {
  111. this.init()
  112. this.calcDiscount()
  113. this.getCropperInfo()
  114. this.getProcessDefinitionId()
  115. },
  116. watch:{
  117. value(){
  118. this.calcDiscount()
  119. }
  120. },
  121. methods: {
  122. calcDiscount() {
  123. let data = this.value / 100
  124. this.form.discount = data == 0 ? 1 : this.value / 100
  125. this.desc = data == 0 || data == 1 ? '无折扣' : (this.value / 10) + '折'
  126. },
  127. isCorrectDiscount() {
  128. let data = parseFloat(this.form.discount)
  129. if (Number.isFinite(data) && data >= 0.1 && data <= 1) {
  130. return true
  131. }
  132. return false
  133. },
  134. timeConfirm(e) {
  135. console.log(e);
  136. let date = e.year + '-' + e.month + '-' + e.day
  137. if (this.timeType == 1) {
  138. this.form.beginTime = date
  139. } else {
  140. this.form.endTime = date
  141. }
  142. },
  143. publish() {
  144. if (!this.form.title) {
  145. this.$refs.toast.warn('请上传活动封面')
  146. return
  147. }
  148. if (!this.form.title) {
  149. this.$refs.toast.warn('请输入活动标题')
  150. return
  151. }
  152. if (!this.form.discount) {
  153. this.$refs.toast.warn('请输入活动折扣')
  154. return
  155. }
  156. if (!this.form.beginTime) {
  157. this.$refs.toast.warn('请选择活动开始时间')
  158. return
  159. }
  160. if (!this.form.endTime) {
  161. this.$refs.toast.warn('请选择活动结束时间')
  162. return
  163. }
  164. if (!this.form.intro) {
  165. this.$refs.toast.warn('请输入活动详情')
  166. return
  167. }
  168. let params=this.$u.deepClone(this.form)
  169. params.beginTime=this.$dateTime.format(new Date(params.beginTime))
  170. params.endTime=this.$dateTime.format(new Date(params.endTime))
  171. this.$api.activity.publish(params).then(res => {
  172. if (res.success) {
  173. let params = {
  174. path: '/pages/index/index',
  175. title: '活动发布成功,请耐心等待审核'
  176. }
  177. uni.redirectTo({
  178. url: '/pages/login/submit-success?params=' + JSON.stringify(params)
  179. })
  180. }
  181. })
  182. },
  183. protocol() {
  184. uni.navigateTo({
  185. url: "/pages/webView/webView?url=" + this.$global.publishActivity
  186. })
  187. },
  188. //获取发布活动流程id
  189. getProcessDefinitionId() {
  190. let params = {
  191. category: 'flow_4',
  192. mode: 1
  193. }
  194. this.$api.flow.getProcessDefinitionId(params).then(res => {
  195. this.form.processDefinitionId = res.data.records[0].id
  196. if (this.$isEmpty(this.form.processDefinitionId)) {
  197. this.$dialog.showModalAndBack("系统错误,获取流程主键失败")
  198. return
  199. }
  200. })
  201. },
  202. init() {
  203. uni.$on('uAvatarCropper', (path) => {
  204. this.$api.uploadFile(path).then(res => {
  205. this.form.poster = res.data.link
  206. })
  207. })
  208. this.form.launchId = this.vuex_shopId
  209. this.form.mallId = this.vuex_mallId
  210. },
  211. async getCropperInfo() {
  212. let scale = 360 / 620
  213. this.rectWidth = parseInt(this.$u.sys().windowWidth - 40)
  214. this.rectHeight = parseInt(this.rectWidth * scale)
  215. },
  216. //图片裁剪
  217. cropperSelect() {
  218. let params = {
  219. destWidth: this.rectWidth,
  220. destHeight: this.rectHeight,
  221. rectWidth: this.rectWidth,
  222. rectHeight: this.rectHeight,
  223. fileType: 'jpg',
  224. }
  225. console.log(params);
  226. uni.navigateTo({
  227. url: "/pages/image-cropper/image-cropper" + this.$u.queryParams(params)
  228. })
  229. },
  230. }
  231. };
  232. </script>
  233. <style lang="scss" scoped>
  234. .cover {
  235. background-color: #FFFFFF;
  236. border-radius: 20rpx;
  237. height: 340rpx;
  238. }
  239. .content {
  240. margin-top: 20rpx;
  241. background-color: #FFFFFF;
  242. border-radius: 20rpx;
  243. padding: 20rpx 30rpx;
  244. .title {
  245. color: #010101;
  246. font-size: 30rpx;
  247. }
  248. }
  249. .badge-button {
  250. padding: 14rpx 16rpx;
  251. background-color: $base-color;
  252. color: #fff;
  253. border-radius: 10rpx;
  254. font-size: 22rpx;
  255. line-height: 1;
  256. }
  257. </style>