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

250 lines
5.3 KiB

  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="input-area">
  17. <view class="label-row">
  18. <text class="required">*</text>
  19. <text class="label">{{ item.title }}</text>
  20. </view>
  21. <input class="input"
  22. v-model="item.levelName"
  23. placeholder="请输入"
  24. placeholder-class="input-placeholder" />
  25. </view>
  26. </view>
  27. <!-- <view class="divider"></view>
  28. <view class="achievement-item">
  29. <image class="badge-img"
  30. 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"
  31. mode="aspectFill" />
  32. <view class="input-area">
  33. <view class="label-row">
  34. <text class="required">*</text>
  35. <text class="label">二级成就名称</text>
  36. </view>
  37. <input class="input" v-model="level2" placeholder="请输入" placeholder-class="input-placeholder" />
  38. </view>
  39. </view>
  40. <view class="divider"></view>
  41. <view class="achievement-item">
  42. <image class="badge-img"
  43. 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"
  44. mode="aspectFill" />
  45. <view class="input-area">
  46. <view class="label-row">
  47. <text class="required">*</text>
  48. <text class="label">三级成就名称</text>
  49. </view>
  50. <input class="input" v-model="level3" placeholder="请输入" placeholder-class="input-placeholder" />
  51. </view>
  52. </view> -->
  53. </view>
  54. </view>
  55. <view class="bottom-btn-area">
  56. <button class="submit-btn" :disabled="isPending" :class="{disabled: isPending, pending: isPending}"
  57. @click="submit">
  58. {{ isPending ? '设置' : '提交申请' }}
  59. </button>
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import mixinsList from '@/mixins/list.js'
  65. export default {
  66. mixins: [mixinsList],
  67. data() {
  68. return {
  69. level1: '',
  70. level2: '',
  71. level3: '',
  72. mixinsListApi : 'getAchievementList',
  73. isPending: false
  74. }
  75. },
  76. methods: {
  77. async submit() {
  78. for (var index = 0; index < this.list.length; index++) {
  79. var element = this.list[index];
  80. if (!element.levelName) {
  81. uni.showToast({
  82. title: '请填写所有成就名称',
  83. icon: 'none'
  84. })
  85. return
  86. }
  87. }
  88. // this.isPending = true
  89. let arr = []
  90. for (var index = 0; index < this.list.length; index++) {
  91. var element = this.list[index];
  92. arr.push(this.$fetch('setAchievementName', {
  93. name : element.levelName
  94. }))
  95. }
  96. await Promise.all(arr)
  97. uni.showToast({
  98. title: '提交成功',
  99. icon: 'none'
  100. })
  101. setTimeout(() => {
  102. uni.navigateBack()
  103. }, 1000)
  104. },
  105. }
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. .achievement-page {
  110. min-height: 100vh;
  111. background: #f7f8fa;
  112. display: flex;
  113. flex-direction: column;
  114. }
  115. .achievement-card {
  116. background: #fff;
  117. border-radius: 20rpx;
  118. margin: 40rpx 32rpx 0 32rpx;
  119. padding: 32rpx 24rpx;
  120. box-shadow: 0 4rpx 24rpx 0 rgba(0, 0, 0, 0.04);
  121. }
  122. .card-title-row {
  123. display: flex;
  124. align-items: center;
  125. justify-content: space-between;
  126. }
  127. .card-title {
  128. font-size: 32rpx;
  129. font-weight: bold;
  130. margin-bottom: 32rpx;
  131. }
  132. .achievement-list {
  133. display: flex;
  134. flex-direction: column;
  135. gap: 0;
  136. }
  137. .achievement-item {
  138. display: flex;
  139. align-items: flex-start;
  140. padding: 18rpx 0 10rpx 0;
  141. }
  142. .badge-img {
  143. width: 72rpx;
  144. height: 72rpx;
  145. margin-right: 20rpx;
  146. border-radius: 50%;
  147. background: #f5f5f5;
  148. object-fit: cover;
  149. border: 2rpx solid #fff;
  150. box-shadow: 0 2rpx 8rpx 0 rgba(0, 0, 0, 0.04);
  151. }
  152. .input-area {
  153. margin-top: 15rpx;
  154. flex: 1;
  155. display: flex;
  156. flex-direction: column;
  157. justify-content: flex-start;
  158. }
  159. .label-row {
  160. display: flex;
  161. align-items: center;
  162. margin-bottom: 6rpx;
  163. }
  164. .required {
  165. color: #e23d3d;
  166. font-size: 28rpx;
  167. margin-right: 4rpx;
  168. }
  169. .label {
  170. font-size: 28rpx;
  171. color: #222;
  172. font-weight: bold;
  173. }
  174. .input {
  175. width: 100%;
  176. border: none;
  177. border-bottom: 1.5rpx solid #ececec;
  178. font-size: 28rpx;
  179. background: transparent;
  180. padding: 8rpx 0 6rpx 0;
  181. margin-bottom: 2rpx;
  182. }
  183. .input-placeholder {
  184. color: #d2d2d2;
  185. font-size: 26rpx;
  186. }
  187. .divider {
  188. height: 1rpx;
  189. background: #f3f3f3;
  190. margin: 0 0 0 92rpx;
  191. }
  192. .bottom-btn-area {
  193. margin-top: auto;
  194. padding: 48rpx 32rpx 32rpx 32rpx;
  195. background: transparent;
  196. }
  197. .submit-btn {
  198. width: 100%;
  199. height: 88rpx;
  200. background: #0a2e6d;
  201. color: #fff;
  202. font-size: 32rpx;
  203. border-radius: 44rpx;
  204. font-weight: bold;
  205. letter-spacing: 2rpx;
  206. transition: background 0.2s;
  207. }
  208. .submit-btn.disabled {
  209. background: #807a7a;
  210. color: #fff;
  211. }
  212. .submit-btn.pending {
  213. background: #0a226d;
  214. color: #fff;
  215. }
  216. .pending-tag {
  217. background: #807a7a;
  218. color: #fff;
  219. font-size: 24rpx;
  220. border-radius: 10rpx;
  221. padding: 6rpx 24rpx;
  222. margin-left: 20rpx;
  223. margin-bottom: 32rpx;
  224. }
  225. </style>