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

279 lines
6.1 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="">
  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" :class="{disabled: isPending, pending: isPending}"
  67. @click="submit">
  68. {{ isPending ? '设置' : '提交申请' }}
  69. </button>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import mixinsList from '@/mixins/list.js'
  75. export default {
  76. mixins: [mixinsList],
  77. data() {
  78. return {
  79. mixinsListApi : 'getAchievementList',
  80. isPending: false,
  81. keys : ['one', 'two', 'three'],
  82. form : {},
  83. }
  84. },
  85. onLoad() {
  86. this.getDetail()
  87. },
  88. methods: {
  89. async getDetail(){
  90. this.form = await this.$fetch('getAchievement')
  91. this.isPending = this.form.status == 0
  92. },
  93. async submit() {
  94. // for (var index = 0; index < this.list.length; index++) {
  95. // var element = this.list[index];
  96. // if (!element.levelName) {
  97. // uni.showToast({
  98. // title: '请填写所有成就名称',
  99. // icon: 'none'
  100. // })
  101. // return
  102. // }
  103. // }
  104. // this.isPending = true
  105. // let arr = []
  106. // for (var index = 0; index < this.list.length; index++) {
  107. // var element = this.list[index];
  108. // arr.push(this.$fetch('setAchievementName', {
  109. // name : element.levelName
  110. // }))
  111. // }
  112. // await Promise.all(arr)
  113. if(this.$utils.verificationAll(this.form, {
  114. oneName : '请填写所有成就名称',
  115. twoName : '请填写所有成就名称',
  116. threeName : '请填写所有成就名称',
  117. })){
  118. return
  119. }
  120. await this.$fetch('setAchievementName', this.form)
  121. uni.showToast({
  122. title: '提交成功',
  123. icon: 'none'
  124. })
  125. setTimeout(() => {
  126. uni.navigateBack()
  127. }, 1000)
  128. },
  129. }
  130. }
  131. </script>
  132. <style scoped lang="scss">
  133. .achievement-page {
  134. min-height: 100vh;
  135. background: #f7f8fa;
  136. display: flex;
  137. flex-direction: column;
  138. }
  139. .achievement-card {
  140. background: #fff;
  141. border-radius: 20rpx;
  142. margin: 40rpx 32rpx 0 32rpx;
  143. padding: 32rpx 24rpx;
  144. box-shadow: 0 4rpx 24rpx 0 rgba(0, 0, 0, 0.04);
  145. }
  146. .card-title-row {
  147. display: flex;
  148. align-items: center;
  149. justify-content: space-between;
  150. }
  151. .card-title {
  152. font-size: 32rpx;
  153. font-weight: bold;
  154. margin-bottom: 32rpx;
  155. }
  156. .achievement-list {
  157. display: flex;
  158. flex-direction: column;
  159. gap: 0;
  160. }
  161. .achievement-item {
  162. display: flex;
  163. align-items: flex-start;
  164. padding: 18rpx 0 10rpx 0;
  165. }
  166. .badge-img {
  167. width: 72rpx;
  168. height: 72rpx;
  169. margin-right: 20rpx;
  170. border-radius: 50%;
  171. background: #f5f5f5;
  172. object-fit: cover;
  173. border: 2rpx solid #fff;
  174. box-shadow: 0 2rpx 8rpx 0 rgba(0, 0, 0, 0.04);
  175. }
  176. .input-area {
  177. margin-top: 15rpx;
  178. flex: 1;
  179. display: flex;
  180. flex-direction: column;
  181. justify-content: flex-start;
  182. }
  183. .label-row {
  184. display: flex;
  185. align-items: center;
  186. margin-bottom: 6rpx;
  187. }
  188. .required {
  189. color: #e23d3d;
  190. font-size: 28rpx;
  191. margin-right: 4rpx;
  192. }
  193. .label {
  194. font-size: 24rpx;
  195. color: #999;
  196. font-weight: bold;
  197. }
  198. .Num{
  199. }
  200. .input {
  201. width: 100%;
  202. border: none;
  203. border-bottom: 1.5rpx solid #ececec;
  204. font-size: 28rpx;
  205. background: transparent;
  206. padding: 16rpx 0;
  207. margin-bottom: 2rpx;
  208. }
  209. .input-placeholder {
  210. color: #d2d2d2;
  211. font-size: 26rpx;
  212. }
  213. .divider {
  214. height: 1rpx;
  215. background: #f3f3f3;
  216. margin: 0 0 0 92rpx;
  217. }
  218. .bottom-btn-area {
  219. margin-top: auto;
  220. padding: 48rpx 32rpx 32rpx 32rpx;
  221. background: transparent;
  222. }
  223. .submit-btn {
  224. width: 100%;
  225. height: 88rpx;
  226. background: #0a2e6d;
  227. color: #fff;
  228. font-size: 32rpx;
  229. border-radius: 44rpx;
  230. font-weight: bold;
  231. letter-spacing: 2rpx;
  232. transition: background 0.2s;
  233. }
  234. .submit-btn.disabled {
  235. background: #807a7a;
  236. color: #fff;
  237. }
  238. .submit-btn.pending {
  239. background: #0a226d;
  240. color: #fff;
  241. }
  242. .pending-tag {
  243. background: #807a7a;
  244. color: #fff;
  245. font-size: 24rpx;
  246. border-radius: 10rpx;
  247. padding: 6rpx 24rpx;
  248. margin-left: 20rpx;
  249. margin-bottom: 32rpx;
  250. }
  251. </style>