裂变星小程序-25.03.04
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

346 lines
9.3 KiB

  1. <template>
  2. <view class="page">
  3. <navbar title="群分享" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="content">
  5. <uv-form
  6. ref="form"
  7. :model="form"
  8. :rules="rules"
  9. labelPosition="left"
  10. labelWidth="300rpx"
  11. :labelStyle="{
  12. color: '#1B1B1B',
  13. fontSize: '32rpx',
  14. fontWeight: 'bold',
  15. }"
  16. errorType="toast"
  17. >
  18. <view class="form-item">
  19. <uv-form-item label="用户ID" prop="userId">
  20. <view class="form-item-content">
  21. <text>{{ userId }}</text>
  22. <view style="margin-left: 20rpx;">
  23. <button class="btn-simple" plain @click="$utils.copyText(userId)">
  24. <uv-icon name="file-text" color="#05D9A2" size="28rpx"></uv-icon>
  25. </button>
  26. </view>
  27. </view>
  28. </uv-form-item>
  29. </view>
  30. <view class="form-item">
  31. <uv-form-item label="选择群头像" prop="headImage">
  32. <view class="form-item-content">
  33. <formUpload v-model="form.headImage">
  34. <template v-slot="{ value }">
  35. <view class="flex" style="min-width: 116rpx; height: 45rpx;">
  36. <image
  37. :src="value"
  38. mode="aspectFill"
  39. style="width: 68rpx; height: 68rpx;"
  40. radius="14rpx"
  41. />
  42. <uv-icon style="margin-left: 20rpx" name="arrow-right" color="#000000" size="28rpx"></uv-icon>
  43. </view>
  44. </template>
  45. </formUpload>
  46. </view>
  47. </uv-form-item>
  48. </view>
  49. <view class="form-item">
  50. <uv-form-item label="群名称" labelWidth="105rpx" prop="headTitle">
  51. <view class="form-item-content">
  52. <formInput v-model="form.headTitle" placeholder="请输入你的群名称" width="540rpx"></formInput>
  53. </view>
  54. </uv-form-item>
  55. </view>
  56. <view class="form-item">
  57. <uv-form-item label="选择群封面图" prop="indexImage">
  58. <view class="form-item-content">
  59. <formUpload v-model="form.indexImage">
  60. <template v-slot="{ value }">
  61. <view class="flex" style="min-width: 116rpx; height: 45rpx;">
  62. <image
  63. :src="value"
  64. mode="aspectFill"
  65. style="width: 68rpx; height: 68rpx;"
  66. radius="14rpx"
  67. />
  68. <uv-icon style="margin-left: 20rpx" name="arrow-right" color="#000000" size="28rpx"></uv-icon>
  69. </view>
  70. </template>
  71. </formUpload>
  72. </view>
  73. </uv-form-item>
  74. </view>
  75. <view class="form-item">
  76. <uv-form-item label="群人数(人)" prop="memberNum">
  77. <view class="form-item-content">
  78. <formNumberBox v-model="form.memberNum" :min="3" inputWidth="80rpx"></formNumberBox>
  79. </view>
  80. </uv-form-item>
  81. </view>
  82. <view class="form-item">
  83. <uv-form-item label="设置转发次数(次)" prop="num">
  84. <view class="form-item-content">
  85. <formNumberBox v-model="form.num" inputWidth="80rpx"></formNumberBox>
  86. </view>
  87. </uv-form-item>
  88. </view>
  89. <view class="form-item">
  90. <uv-form-item label="选择二维码" prop="wxCodeImage">
  91. <view class="form-item-content">
  92. <formUpload v-model="form.wxCodeImage">
  93. <template v-slot="{ value }">
  94. <view class="flex" style="min-width: 93rpx; height: 45rpx;">
  95. <image
  96. :src="value"
  97. mode="aspectFill"
  98. style="width: 45rpx; height: 45rpx;"
  99. radius="14rpx"
  100. />
  101. <uv-icon style="margin-left: 20rpx" name="arrow-right" color="#000000" size="28rpx"></uv-icon>
  102. </view>
  103. </template>
  104. </formUpload>
  105. </view>
  106. </uv-form-item>
  107. </view>
  108. <view class="form-item">
  109. <uv-form-item label="文案描述" prop="textDetails" labelPosition="top">
  110. <view style="margin-top: 32rpx;">
  111. <formTextarea
  112. v-model="form.textDetails"
  113. placeholder="请输入你的文案"
  114. ></formTextarea>
  115. </view>
  116. </uv-form-item>
  117. </view>
  118. </uv-form>
  119. </view>
  120. <!-- 审核通过 -->
  121. <button v-if="status === 1" class="button-submit" open-type="share">
  122. 发布
  123. </button>
  124. <!-- 不是 审核中 已发布 -> 创建分享 审核不通过 -->
  125. <button v-else-if="![0,1].includes(status)" class="button-submit" @click="onSubmit">
  126. 提交审核
  127. </button>
  128. </view>
  129. </template>
  130. <script>
  131. import { mapState } from 'vuex'
  132. import formInput from '../components/formInput.vue'
  133. import formNumberBox from '../components/formNumberBox.vue'
  134. import formUpload from '../components/formUpload.vue'
  135. import formTextarea from '../components/formTextarea.vue'
  136. export default {
  137. components: {
  138. formInput,
  139. formNumberBox,
  140. formUpload,
  141. formTextarea,
  142. },
  143. data() {
  144. return {
  145. id: null,
  146. status: null,
  147. form: {
  148. userId: null,
  149. headImage: null,
  150. headTitle: null,
  151. indexImage: null,
  152. memberNum: 50,
  153. num: 0,
  154. wxCodeImage: null,
  155. textDetails: null,
  156. },
  157. rules: {
  158. 'headImage': {
  159. type: 'string',
  160. required: true,
  161. message: '请选择群头像',
  162. },
  163. 'headTitle': {
  164. type: 'string',
  165. required: true,
  166. message: '请输入你的群名称',
  167. },
  168. 'indexImage': {
  169. type: 'string',
  170. required: true,
  171. message: '请选择群封面图',
  172. },
  173. 'memberNum': {
  174. type: 'number',
  175. required: true,
  176. message: '请填写群人数',
  177. },
  178. 'num': {
  179. type: 'number',
  180. required: true,
  181. message: '请设置转发次数(大于0)',
  182. validator: (rule, value, callback) => {
  183. if (value > 0) {
  184. return true
  185. }
  186. return false;
  187. },
  188. },
  189. 'wxCodeImage': {
  190. type: 'string',
  191. required: true,
  192. message: '请选择二维码',
  193. },
  194. 'textDetails': {
  195. type: 'string',
  196. required: true,
  197. message: '请输入你的文案',
  198. },
  199. },
  200. }
  201. },
  202. computed: {
  203. ...mapState(['configList', 'userInfo']),
  204. userId() {
  205. return this.form.userId || this.userInfo?.id
  206. },
  207. },
  208. onLoad(option) {
  209. const { id } = option
  210. if (!id) {
  211. this.form.headImage = this.configList.index_sign
  212. return
  213. }
  214. this.id = id
  215. this.fetchDetails(id)
  216. },
  217. onReady() {
  218. this.$refs.form.setRules(this.rules);
  219. },
  220. onShareAppMessage(res) {
  221. const {
  222. textDetails,
  223. indexImage,
  224. } = this.form
  225. let o = {
  226. title : textDetails,
  227. imageUrl: indexImage,
  228. path: `/pages_order/sharing/group?id=${this.id}&state=2&shareId=${this.userInfo.id}`
  229. }
  230. //调用增加分享次数的方法
  231. const params = {
  232. id:this.id,
  233. state:"3",
  234. }
  235. this.$fetch('addLogShareInfo', params)
  236. this.isLocked = false
  237. return o
  238. },
  239. methods: {
  240. async fetchDetails(id) {
  241. try {
  242. const result = await this.$fetch('getGroupShareInfo', { id })
  243. const {
  244. userId,
  245. headImage,
  246. headTitle,
  247. indexImage,
  248. memberNum,
  249. num,
  250. wxCodeImage,
  251. textDetails,
  252. status,
  253. } = result || {}
  254. this.form = {
  255. userId,
  256. headImage,
  257. headTitle,
  258. indexImage,
  259. memberNum,
  260. num,
  261. wxCodeImage,
  262. textDetails,
  263. }
  264. this.status = status
  265. } catch (err) {
  266. }
  267. },
  268. async onSubmit() {
  269. try {
  270. await this.$refs.form.validate()
  271. const {
  272. headImage,
  273. headTitle,
  274. indexImage,
  275. memberNum,
  276. num,
  277. wxCodeImage,
  278. textDetails,
  279. } = this.form
  280. const params = {
  281. userId: this.userId,
  282. headImage,
  283. headTitle,
  284. indexImage,
  285. memberNum,
  286. num,
  287. wxCodeImage,
  288. textDetails,
  289. }
  290. if (this.id) {
  291. params.id = this.id
  292. }
  293. await this.$fetch('saveOrUpdateGroupShare', params)
  294. uni.showToast({
  295. title: '提交成功',
  296. icon: 'none'
  297. })
  298. setTimeout(uni.navigateBack, 1000, -1)
  299. } catch (err) {
  300. }
  301. },
  302. onPublish() {
  303. // todo
  304. },
  305. }
  306. }
  307. </script>
  308. <style scoped lang="scss">
  309. @import '../styles/pageForm.scss';
  310. .button-submit {
  311. margin: 0;
  312. position: fixed;
  313. bottom: 138rpx;
  314. left: 20rpx;
  315. width: calc(100% - 40rpx);
  316. height: 90rpx;
  317. }
  318. </style>