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

341 lines
9.1 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
  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. // todo: get times and check is unlocked
  231. this.isLocked = false
  232. return o
  233. },
  234. methods: {
  235. async fetchDetails(id) {
  236. try {
  237. const result = await this.$fetch('getGroupShareInfo', { id })
  238. const {
  239. userId,
  240. headImage,
  241. headTitle,
  242. indexImage,
  243. memberNum,
  244. num,
  245. wxCodeImage,
  246. textDetails,
  247. status,
  248. } = result || {}
  249. this.form = {
  250. userId,
  251. headImage,
  252. headTitle,
  253. indexImage,
  254. memberNum,
  255. num,
  256. wxCodeImage,
  257. textDetails,
  258. }
  259. this.status = status
  260. } catch (err) {
  261. }
  262. },
  263. async onSubmit() {
  264. try {
  265. await this.$refs.form.validate()
  266. const {
  267. headImage,
  268. headTitle,
  269. indexImage,
  270. memberNum,
  271. num,
  272. wxCodeImage,
  273. textDetails,
  274. } = this.form
  275. const params = {
  276. userId: this.userId,
  277. headImage,
  278. headTitle,
  279. indexImage,
  280. memberNum,
  281. num,
  282. wxCodeImage,
  283. textDetails,
  284. }
  285. if (this.id) {
  286. params.id = this.id
  287. }
  288. await this.$fetch('saveOrUpdateGroupShare', params)
  289. uni.showToast({
  290. title: '提交成功',
  291. icon: 'none'
  292. })
  293. setTimeout(uni.navigateBack, 1000, -1)
  294. } catch (err) {
  295. }
  296. },
  297. onPublish() {
  298. // todo
  299. },
  300. }
  301. }
  302. </script>
  303. <style scoped lang="scss">
  304. @import '../styles/pageForm.scss';
  305. .button-submit {
  306. margin: 0;
  307. position: fixed;
  308. bottom: 138rpx;
  309. left: 20rpx;
  310. width: calc(100% - 40rpx);
  311. height: 90rpx;
  312. }
  313. </style>