xq-csg-weapp_uni-ts
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

228 lines
5.5KB

  1. <template>
  2. <view>
  3. <custom-nav-bar position="fixed" color="black" left-text="评价" left-arrow />
  4. <view class="appraise flex flex-v-center">
  5. <view class="mr-25">满意度:</view>
  6. <block v-for="item in 5" :key="item">
  7. <image src="/static/images/void-icon2.png" v-if="form.appraiseStar >= item" @click="headleChange(item)" style="width: 36rpx;height: 36rpx;margin-right: 10rpx;" mode=""></image>
  8. <image src="/static/images/rate-icon.png" v-else @click="headleChange(item)" style="width: 36rpx;height: 36rpx;margin-right: 10rpx;" mode=""></image>
  9. </block>
  10. </view>
  11. <view class="division"></view>
  12. <!-- 描述 -->
  13. <view class="describe">
  14. <view>描述</view>
  15. <textarea class="textarea" placeholder="请输入" @input="headleInput" maxlength="300" :value="form.title"
  16. data-name="appraiseContent" focus auto-height></textarea>
  17. <view class="form-image">
  18. <van-uploader :after-read="afterRead" v-model="fileList" :deletable="true" max-count="9"
  19. :delete="imageDelete">
  20. <image class="camera" src="/static/images/icon9.png"></image>
  21. </van-uploader>
  22. </view>
  23. </view>
  24. <view class="van-button">
  25. <van-button color="#fe3b53" v-if="form.appraiseContent === '' && form.appraiseStar === 0" block>
  26. 提交评价
  27. </van-button>
  28. <van-button color="#fe3b53" @tap.native="submit" v-if="form.appraiseContent !== '' || form.appraiseStar !== 0" block>
  29. 提交评价
  30. </van-button>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. // const app = getApp();
  36. // const { peopleApi } = app.globalData.api;
  37. import * as peopleApi from '@/api/peopleApi';
  38. import * as publicApi from '@/api/publicApi';
  39. export default {
  40. components: {},
  41. data() {
  42. return {
  43. // 上传图片所需
  44. appealEnclosure: [],
  45. fileList: [],
  46. options: null,
  47. form: {
  48. appraiseContent: '',
  49. appraiseStar: 0,
  50. title: ''
  51. },
  52. name: ''
  53. };
  54. },
  55. onLoad(options) {
  56. this.options = options
  57. },
  58. methods: {
  59. headleChange(event) {
  60. this.form.appraiseStar = event
  61. },
  62. // 上传图片
  63. async afterRead(event) {
  64. const {
  65. file
  66. } = event;
  67. const res = await getApp().globalData.upload({
  68. file
  69. });
  70. if (res.code !== 0) {
  71. uni.showToast({
  72. title: '上传图片失败',
  73. icon: 'none'
  74. });
  75. return false;
  76. }
  77. const url = res.data;
  78. // this.fileList.push({url});
  79. this.appealEnclosure.push(url);
  80. },
  81. // 清楚对应的image图片
  82. imageDelete(event) {
  83. const {
  84. index
  85. } = event.detail;
  86. this.fileList.splice(index, 1);
  87. this.appealEnclosure.splice(index,1)
  88. },
  89. headleInput(event) {
  90. const {
  91. value
  92. } = event.detail;
  93. const {
  94. name
  95. } = event.currentTarget.dataset;
  96. this.form[name] = value;
  97. this[name] = this[name]
  98. },
  99. // 提交
  100. async submit() {
  101. const {
  102. appraiseContent,
  103. appraiseStar
  104. } = this.form;
  105. if (appraiseStar === 0 || appraiseContent === '') {
  106. let toastTitle = '';
  107. if (appraiseStar === 0) {
  108. toastTitle = '请输入满意度不能为空';
  109. } else if (appraiseContent === '') {
  110. toastTitle = '请输入描述';
  111. } else {
  112. toastTitle = '带*属于必填项';
  113. }
  114. uni.showToast({
  115. title: toastTitle,
  116. icon: 'none'
  117. });
  118. return false;
  119. }
  120. let params = {
  121. id: this.options.id,
  122. appraiseContent: appraiseContent,
  123. appraiseStar: appraiseStar,
  124. appraiseImage: this.appealEnclosure
  125. };
  126. console.log(params);
  127. const res = await peopleApi.CrateAppraiseApi(params);
  128. if (res.code !== 0) {
  129. uni.showToast({
  130. title: res.msg,
  131. icon: 'none'
  132. });
  133. return;
  134. }
  135. uni.showToast({
  136. title: '评论成功',
  137. icon: 'none'
  138. });
  139. uni.redirectTo({
  140. url: '/packages/people/pages/masses/masses'
  141. });
  142. }
  143. }
  144. };
  145. </script>
  146. <style lang="less">
  147. .appraise {
  148. padding: 60rpx 40rpx;
  149. font-size: 32rpx;
  150. color: #333333;
  151. font-weight: 400;
  152. line-height: 32rpx;
  153. }
  154. .mr-25 {
  155. margin-right: 25rpx;
  156. }
  157. .division {
  158. height: 20rpx;
  159. background: #f9f9f9;
  160. }
  161. .describe {
  162. background: #ffffff;
  163. border-radius: 16px;
  164. padding: 40rpx 40rpx 150rpx 40rpx;
  165. font-size: 28rpx;
  166. font-weight: 400;
  167. color: #333333;
  168. .textarea {
  169. padding: 24rpx 0;
  170. padding-top: 20rpx;
  171. }
  172. .form-image {
  173. margin: 20rpx 0rpx 50rpx 0;
  174. display: flex;
  175. align-items: center;
  176. flex-wrap: wrap;
  177. }
  178. .form-image>view {
  179. width: 31.3%;
  180. position: relative;
  181. margin-right: 13.5rpx;
  182. }
  183. .form-image>view>image:nth-child(1) {
  184. width: 100%;
  185. height: 200rpx;
  186. border-radius: 10rpx;
  187. }
  188. .form-image>view>image:nth-child(2) {
  189. position: absolute;
  190. top: -0rpx;
  191. right: 0rpx;
  192. width: 40rpx;
  193. height: 40rpx;
  194. }
  195. .camera {
  196. width: 160rpx;
  197. height: 160rpx;
  198. border-radius: 8rpx;
  199. }
  200. }
  201. .van-button {
  202. width: 100%;
  203. position: fixed;
  204. bottom: 0;
  205. z-index: 99;
  206. background-color: #fff;
  207. }
  208. </style>