小说小程序前端代码仓库(小程序)
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.

291 lines
6.4 KiB

2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
  1. <template>
  2. <view class="achievement-page">
  3. <navbar title="读者成就设置" leftClick @leftClick="$utils.navigateBack" />
  4. <view class="achievement-card">
  5. <view class="card-title-row">
  6. <view class="card-title">阅读成就设置</view>
  7. <view v-if="isPending" class="pending-tag">设置审核中</view>
  8. </view>
  9. <view class="achievement-list">
  10. <view class="achievement-item"
  11. v-for="(item, index) in list"
  12. :key="index">
  13. <image class="badge-img"
  14. :src="item.image"
  15. mode="aspectFill" />
  16. <view class="">
  17. <view class="input-area">
  18. <view class="label-row">
  19. <text class="required">*</text>
  20. <text class="label">{{ item.title }}</text>
  21. </view>
  22. <input class="input"
  23. v-model="form[keys[index] + 'Name']"
  24. placeholder="请输入"
  25. placeholder-class="input-placeholder" />
  26. </view>
  27. <view class="input-area" v-if="form[keys[index] + 'Num']">
  28. <view class="label-row">
  29. <text class="label">达成人数</text>
  30. </view>
  31. <view class="Num">
  32. {{ form[keys[index] + 'Num'] || 0 }}
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <!-- <view class="divider"></view>
  38. <view class="achievement-item">
  39. <image class="badge-img"
  40. src="https://tse3-mm.cn.bing.net/th/id/OIP-C.wUsFZgl70iE4tI7b_HKaKgHaHa?w=166&h=180&c=7&r=0&o=5&dpr=1.1&pid=1.7"
  41. mode="aspectFill" />
  42. <view class="input-area">
  43. <view class="label-row">
  44. <text class="required">*</text>
  45. <text class="label">二级成就名称</text>
  46. </view>
  47. <input class="input" v-model="level2" placeholder="请输入" placeholder-class="input-placeholder" />
  48. </view>
  49. </view>
  50. <view class="divider"></view>
  51. <view class="achievement-item">
  52. <image class="badge-img"
  53. src="https://tse3-mm.cn.bing.net/th/id/OIP-C.wUsFZgl70iE4tI7b_HKaKgHaHa?w=166&h=180&c=7&r=0&o=5&dpr=1.1&pid=1.7"
  54. mode="aspectFill" />
  55. <view class="input-area">
  56. <view class="label-row">
  57. <text class="required">*</text>
  58. <text class="label">三级成就名称</text>
  59. </view>
  60. <input class="input" v-model="level3" placeholder="请输入" placeholder-class="input-placeholder" />
  61. </view>
  62. </view> -->
  63. </view>
  64. </view>
  65. <view class="bottom-btn-area">
  66. <button class="submit-btn" :disabled="isPending"
  67. :class="{disabled: isPending}"
  68. @click="submit">
  69. {{ form.id ? '设置' : '提交申请' }}
  70. </button>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import mixinsList from '@/mixins/list.js'
  76. export default {
  77. mixins: [mixinsList],
  78. data() {
  79. return {
  80. mixinsListApi : 'getAchievementList',
  81. isPending: false,
  82. keys : ['one', 'two', 'three'],
  83. form : {},
  84. }
  85. },
  86. onLoad() {
  87. this.getDetail()
  88. },
  89. methods: {
  90. async getDetail(){
  91. this.form = await this.$fetch('getAchievement') || {}
  92. this.isPending = this.form.status == 0
  93. },
  94. async submit() {
  95. // for (var index = 0; index < this.list.length; index++) {
  96. // var element = this.list[index];
  97. // if (!element.levelName) {
  98. // uni.showToast({
  99. // title: '请填写所有成就名称',
  100. // icon: 'none'
  101. // })
  102. // return
  103. // }
  104. // }
  105. // this.isPending = true
  106. // let arr = []
  107. // for (var index = 0; index < this.list.length; index++) {
  108. // var element = this.list[index];
  109. // arr.push(this.$fetch('setAchievementName', {
  110. // name : element.levelName
  111. // }))
  112. // }
  113. // await Promise.all(arr)
  114. if(this.$utils.verificationAll(this.form, {
  115. oneName : '请填写' + this.list[0].title,
  116. twoName : '请填写' + this.list[1].title,
  117. threeName : '请填写' + this.list[2].title,
  118. })){
  119. return
  120. }
  121. let data = {
  122. oneName : this.form.oneName,
  123. twoName : this.form.twoName,
  124. threeName : this.form.threeName,
  125. status : 0
  126. }
  127. if(this.form.id){
  128. data.id = this.form.id
  129. }
  130. await this.$fetch('setAchievementName', data)
  131. uni.showToast({
  132. title: '提交成功',
  133. icon: 'none'
  134. })
  135. setTimeout(() => {
  136. uni.navigateBack()
  137. }, 1000)
  138. },
  139. }
  140. }
  141. </script>
  142. <style scoped lang="scss">
  143. .achievement-page {
  144. min-height: 100vh;
  145. background: #f7f8fa;
  146. display: flex;
  147. flex-direction: column;
  148. }
  149. .achievement-card {
  150. background: #fff;
  151. border-radius: 20rpx;
  152. margin: 40rpx 32rpx 0 32rpx;
  153. padding: 32rpx 24rpx;
  154. box-shadow: 0 4rpx 24rpx 0 rgba(0, 0, 0, 0.04);
  155. }
  156. .card-title-row {
  157. display: flex;
  158. align-items: center;
  159. justify-content: space-between;
  160. }
  161. .card-title {
  162. font-size: 32rpx;
  163. font-weight: bold;
  164. margin-bottom: 32rpx;
  165. }
  166. .achievement-list {
  167. display: flex;
  168. flex-direction: column;
  169. gap: 0;
  170. }
  171. .achievement-item {
  172. display: flex;
  173. align-items: flex-start;
  174. padding: 18rpx 0 10rpx 0;
  175. }
  176. .badge-img {
  177. width: 72rpx;
  178. height: 72rpx;
  179. margin-right: 20rpx;
  180. border-radius: 50%;
  181. background: #f5f5f5;
  182. object-fit: cover;
  183. border: 2rpx solid #fff;
  184. box-shadow: 0 2rpx 8rpx 0 rgba(0, 0, 0, 0.04);
  185. }
  186. .input-area {
  187. margin-top: 15rpx;
  188. flex: 1;
  189. display: flex;
  190. flex-direction: column;
  191. justify-content: flex-start;
  192. }
  193. .label-row {
  194. display: flex;
  195. align-items: center;
  196. margin-bottom: 6rpx;
  197. }
  198. .required {
  199. color: #e23d3d;
  200. font-size: 28rpx;
  201. margin-right: 4rpx;
  202. }
  203. .label {
  204. font-size: 24rpx;
  205. color: #999;
  206. font-weight: bold;
  207. }
  208. .Num{
  209. }
  210. .input {
  211. width: 100%;
  212. border: none;
  213. border-bottom: 1.5rpx solid #ececec;
  214. font-size: 28rpx;
  215. background: transparent;
  216. padding: 16rpx 0;
  217. margin-bottom: 2rpx;
  218. }
  219. .input-placeholder {
  220. color: #d2d2d2;
  221. font-size: 26rpx;
  222. }
  223. .divider {
  224. height: 1rpx;
  225. background: #f3f3f3;
  226. margin: 0 0 0 92rpx;
  227. }
  228. .bottom-btn-area {
  229. margin-top: auto;
  230. padding: 48rpx 32rpx 32rpx 32rpx;
  231. background: transparent;
  232. }
  233. .submit-btn {
  234. width: 100%;
  235. height: 88rpx;
  236. background: #0a2e6d;
  237. color: #fff;
  238. font-size: 32rpx;
  239. border-radius: 44rpx;
  240. font-weight: bold;
  241. letter-spacing: 2rpx;
  242. transition: background 0.2s;
  243. }
  244. .submit-btn.disabled {
  245. background: #aaa;
  246. color: #fff;
  247. }
  248. .submit-btn.pending {
  249. background: #0a226d;
  250. color: #fff;
  251. }
  252. .pending-tag {
  253. background: #807a7a;
  254. color: #fff;
  255. font-size: 24rpx;
  256. border-radius: 10rpx;
  257. padding: 6rpx 24rpx;
  258. margin-left: 20rpx;
  259. margin-bottom: 32rpx;
  260. }
  261. </style>