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

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