裂变星小程序-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.

357 lines
9.6 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
1 month ago
2 months ago
  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="preSubmit">
  126. 提交审核
  127. </button>
  128. <autoCrop ref="autoCropRef" @change="onSubmit"></autoCrop>
  129. </view>
  130. </template>
  131. <script>
  132. import { mapState } from 'vuex'
  133. import formInput from '../components/formInput.vue'
  134. import formNumberBox from '../components/formNumberBox.vue'
  135. import formUpload from '../components/formUpload.vue'
  136. import formTextarea from '../components/formTextarea.vue'
  137. import autoCrop from '../components/autoCrop.vue'
  138. export default {
  139. components: {
  140. formInput,
  141. formNumberBox,
  142. formUpload,
  143. formTextarea,
  144. autoCrop,
  145. },
  146. data() {
  147. return {
  148. id: null,
  149. status: null,
  150. form: {
  151. userId: null,
  152. headImage: null,
  153. headTitle: null,
  154. indexImage: null,
  155. memberNum: 50,
  156. num: 0,
  157. wxCodeImage: null,
  158. textDetails: null,
  159. },
  160. rules: {
  161. 'headImage': {
  162. type: 'string',
  163. required: true,
  164. message: '请选择群头像',
  165. },
  166. 'headTitle': {
  167. type: 'string',
  168. required: true,
  169. message: '请输入你的群名称',
  170. },
  171. 'indexImage': {
  172. type: 'string',
  173. required: true,
  174. message: '请选择群封面图',
  175. },
  176. 'memberNum': {
  177. type: 'number',
  178. required: true,
  179. message: '请填写群人数',
  180. },
  181. 'num': {
  182. type: 'number',
  183. required: true,
  184. message: '请设置转发次数(大于0)',
  185. validator: (rule, value, callback) => {
  186. if (value > 0) {
  187. return true
  188. }
  189. return false;
  190. },
  191. },
  192. 'wxCodeImage': {
  193. type: 'string',
  194. required: true,
  195. message: '请选择二维码',
  196. },
  197. 'textDetails': {
  198. type: 'string',
  199. required: true,
  200. message: '请输入你的文案',
  201. },
  202. },
  203. }
  204. },
  205. computed: {
  206. ...mapState(['configList', 'userInfo']),
  207. userId() {
  208. return this.userInfo?.intentionCode
  209. },
  210. },
  211. onLoad(option) {
  212. const { id } = option
  213. if (!id) {
  214. this.form.headImage = this.configList.index_sign
  215. return
  216. }
  217. this.id = id
  218. this.fetchDetails(id)
  219. },
  220. onReady() {
  221. this.$refs.form.setRules(this.rules);
  222. },
  223. onShareAppMessage(res) {
  224. const {
  225. textDetails,
  226. indexImage,
  227. } = this.form
  228. let o = {
  229. title : textDetails,
  230. imageUrl: indexImage,
  231. path: `/pages_order/sharing/group?id=${this.id}&state=2&shareId=${this.userInfo.id}`
  232. }
  233. //调用增加分享次数的方法
  234. const params = {
  235. id:this.id,
  236. state:"2",
  237. }
  238. this.$fetch('addLogShareInfo', params)
  239. this.isLocked = false
  240. return o
  241. },
  242. methods: {
  243. async fetchDetails(id) {
  244. try {
  245. const result = await this.$fetch('getGroupShareInfo', { id })
  246. const {
  247. userId,
  248. headImage,
  249. headTitle,
  250. indexImage,
  251. memberNum,
  252. num,
  253. wxCodeImage,
  254. textDetails,
  255. status,
  256. } = result || {}
  257. this.form = {
  258. userId,
  259. headImage,
  260. headTitle,
  261. indexImage,
  262. memberNum,
  263. num,
  264. wxCodeImage,
  265. textDetails,
  266. }
  267. this.status = status
  268. } catch (err) {
  269. }
  270. },
  271. async preSubmit() {
  272. try {
  273. await this.$refs.form.validate()
  274. this.$refs.autoCropRef.set(this.form.indexImage)
  275. } catch (err) {
  276. }
  277. },
  278. async onSubmit(indexImage) {
  279. try {
  280. await this.$refs.form.validate()
  281. const {
  282. headImage,
  283. headTitle,
  284. memberNum,
  285. num,
  286. wxCodeImage,
  287. textDetails,
  288. } = this.form
  289. const params = {
  290. userId: this.userId,
  291. headImage,
  292. headTitle,
  293. indexImage,
  294. memberNum,
  295. num,
  296. wxCodeImage,
  297. textDetails,
  298. }
  299. if (this.id) {
  300. params.id = this.id
  301. }
  302. await this.$fetch('saveOrUpdateGroupShare', params)
  303. uni.showToast({
  304. title: '提交成功',
  305. icon: 'none'
  306. })
  307. setTimeout(uni.navigateBack, 1000, -1)
  308. } catch (err) {
  309. }
  310. },
  311. onPublish() {
  312. // todo
  313. },
  314. }
  315. }
  316. </script>
  317. <style scoped lang="scss">
  318. @import '../styles/pageForm.scss';
  319. .button-submit {
  320. margin: 0;
  321. position: fixed;
  322. bottom: 138rpx;
  323. left: 20rpx;
  324. width: calc(100% - 40rpx);
  325. height: 90rpx;
  326. }
  327. </style>