選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

equity-product-evaluation.vue 9.5KB

1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
9ヶ月前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
9ヶ月前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
1年前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407
  1. <template>
  2. <!-- 权益产品评价 -->
  3. <view class="card" style="padding: 40rpx 30rpx;">
  4. <view class="title">权益产品评价</view>
  5. <!-- <evaluate-star v-model="state.interest.score" title="评价得分"></evaluate-star> -->
  6. <view class="evaluate-star">
  7. <view class="evaluate_title" v-if="title">{{title}}</view>
  8. <view class="star-row">
  9. <view class="star-box" v-for="(item,index) in total" @click="changeRate(index)" :key="index"
  10. :style="style">
  11. <image class="star-img" :src="`${$imgUrl}common/whole_star.png`" v-if="whole-0.5>index" />
  12. <image :class="['star-img',whole-0.5>index?'star-hide':'']" :src="`${$imgUrl}common/half_star.png`"
  13. v-if="half && whole>index" />
  14. <image class="star-img" :src="`${$imgUrl}common/empty_star.png`" v-if="whole<=index" />
  15. </view>
  16. </view>
  17. </view>
  18. <textarea class="input-box" v-model="state.interest.content" placeholder-class="text-hint" :maxlength="300"
  19. style="height: 260rpx;" placeholder="从多角度评价,可以帮助我们提升服务质量。">
  20. </textarea>
  21. <view class="upload-img">
  22. <form-image @backImg="backImgInterest($event)" @removeImg="removeImgInterest" :isUrl="false"
  23. style="width: 100%;" :retract="-15"></form-image>
  24. </view>
  25. </view>
  26. <view class="uni-list" style='font-size:32rpx'>
  27. <view class="uni-list-cell uni-list-cell-pd">
  28. <view class="uni-list-cell-db">是否匿名</view>
  29. <switch style="transform:scale(0.7)" @change="switchChange" />
  30. </view>
  31. </view>
  32. <view class="btn">
  33. <submit-button @submit="publish" title="发布"></submit-button>
  34. </view>
  35. <!-- 选择标签弹窗 -->
  36. <u-popup v-model="state.showTagPop" mode="bottom" height="60%">
  37. <view v-if="state.showTagPop">
  38. <tag-popup :selTags="state.user.tagList" :tagAllList="state.tagAllList"
  39. @cancel="state.showTagPop = !state.showTagPop" @confirm="confirmSelectTag"></tag-popup>
  40. </view>
  41. </u-popup>
  42. </template>
  43. <script setup lang="ts">
  44. // import evaluateStar from "@/subpackage/orders/components/evaluate-star.vue"
  45. import { reactive, onMounted, ref } from "vue";
  46. import { confirm, isBlank, msg } from "@/utils/utils";
  47. import tagPopup from "@/subpackage/orders/components/popup-order-evaluate-tag";
  48. import { request, requestNew } from "@/utils/network/request";
  49. import { orderDetail, addEvaluation, addProductInterestApi } from "@/utils/network/api";
  50. import { onLoad } from "@dcloudio/uni-app";
  51. import { stringToJson } from "@/utils/network/encryption";
  52. import { getItem, StorageKeys } from "@/utils/storage";
  53. const state = reactive({
  54. orderInfo: {} as any, //订单信息
  55. showTagPop: false, //显示标签选择弹窗
  56. product: { //产品
  57. score: 0, //星级得分 最高5分,0.5小数点 2.5分及以下为差评 2.5以上4.0以下为中评 4.0及4.0以上为好评(必选)
  58. content: '', //评价内容
  59. imageList: [], //支持拍照上传最多上传9张
  60. },
  61. interest: { //产品
  62. score: 0, //星级得分 最高5分,0.5小数点 2.5分及以下为差评 2.5以上4.0以下为中评 4.0及4.0以上为好评(必选)
  63. content: '', //评价内容
  64. imageList: [], //支持拍照上传最多上传9张
  65. },
  66. user: { //业务员
  67. score: 0, //星级得分 最高5分,0.5小数点 2.5分及以下为差评 2.5以上4.0以下为中评 4.0及4.0以上为好评(必选)
  68. content: '', //评价内容
  69. tagList: [], //已选择的评价标签列表
  70. },
  71. tagAllList: [],
  72. orderId: "",
  73. haveInterestsProduct: false, //是否有权益产品
  74. isAnonymity: 0, //是否匿名
  75. equityId: "",
  76. id: ""
  77. })
  78. const props = defineProps({
  79. //双向绑定数据
  80. modelValue: {
  81. type: Number,
  82. default: 0
  83. },
  84. //评分总数
  85. total: {
  86. type: Number,
  87. default: 5
  88. },
  89. //评分名称
  90. title: {
  91. type: String,
  92. default: ''
  93. },
  94. //星星大小rpx
  95. size: {
  96. type: Number,
  97. default: 48
  98. }
  99. })
  100. const whole = ref(0)
  101. const half = ref(false)
  102. const sum = ref(0)
  103. let style = reactive({})
  104. /* 确认选择tag */
  105. const confirmSelectTag = (selectTag) => {
  106. state.showTagPop = !state.showTagPop
  107. state.user.tagList = [...selectTag];
  108. }
  109. //选择图片
  110. const backImg = (e : any) => {
  111. console.log("e", e)
  112. state.product.imageList = e;
  113. }
  114. //删除图片
  115. const removeImg = (imgList) => {
  116. state.product.imageList = imgList
  117. }
  118. //选择图片权益产品
  119. const backImgInterest = (e : any) => {
  120. state.interest.imageList = e;
  121. }
  122. //删除图片
  123. const removeImgInterest = (imgList) => {
  124. state.interest.imageList = imgList
  125. }
  126. /* 删除评价标签 */
  127. const removeTag = (item : any) => {
  128. state.user.tagList.map((tag, index) => {
  129. if (tag.id === item.id) {
  130. state.user.tagList.splice(index, 1)
  131. }
  132. })
  133. }
  134. /* 发布 */
  135. const publish = (e) => {
  136. addProductInterest();
  137. }
  138. const addProductInterest = () => {
  139. if (state.interest.score === 0) {
  140. msg('请对权益产品进行打分!');
  141. return;
  142. }
  143. //若不填评价内容,根据打分规则自动填充评价内容
  144. //差评展示:默认差评 2.5分及以下
  145. //中评展示:默认中评 2.5以上4.0以下
  146. //好评展示:默认好评 4.0及4.0以上
  147. if (!state.interest.content) {
  148. if (state.interest.score <= 2.5) {
  149. state.interest.content = "默认差评";
  150. } else if (state.interest.score > 2.5 && state.interest.score < 4) {
  151. state.interest.content = "默认中评";
  152. } else {
  153. state.interest.content = "默认好评";
  154. }
  155. }
  156. const options = {
  157. type: 2,
  158. data: {
  159. "orderId": state.orderId,
  160. "serviceType": "equity",
  161. "equityId": state.equityId,//权益产品id
  162. "score": state.interest.score,
  163. "pictureUrl": state.interest.imageList.join(";"),
  164. "message": '',
  165. "suggestion": state.interest.content,
  166. "isAnonymity": state.isAnonymity, //是否匿名
  167. "type": 1 //区分其他评价
  168. },
  169. method: 'POST',
  170. showLoading: true,
  171. }
  172. console.log("options", options)
  173. requestNew(addEvaluation, options).then((res) => {
  174. addProductInterestRequest()
  175. })
  176. }
  177. /* 完成评价掉接口 */
  178. const addProductInterestRequest = () => {
  179. const options = {
  180. type: 2,
  181. data: { "id": state.id },
  182. method: 'POST',
  183. showLoading: true,
  184. }
  185. request(addProductInterestApi, options).then((res) => {
  186. confirm('您的评价已发布成功!', () => {
  187. uni.$emit('refreshOrder');
  188. uni.navigateBack();
  189. }, '发布成功', false);
  190. })
  191. }
  192. // 是否匿名
  193. const switchChange = (e) => {
  194. console.log('switch1 发生 change 事件,携带值为', e.detail.value);
  195. if (e.detail.value == true) {
  196. state.isAnonymity = 1
  197. } else {
  198. state.isAnonymity = 0
  199. }
  200. }
  201. onLoad((option) => {
  202. console.log("option11111", option)
  203. state.equityId = option.equityId
  204. state.id = option.id
  205. state.orderId = option.orderId
  206. })
  207. onMounted(() => {
  208. style = {
  209. width: props.size + 'rpx',
  210. height: props.size + 'rpx',
  211. }
  212. })
  213. const changeRate = (e) => {
  214. var a = e++
  215. sum.value++
  216. if (sum.value === 1) {
  217. whole.value = e - 0.5
  218. half.value = true
  219. sum.value = -1
  220. } else {
  221. half.value = false
  222. whole.value = e++
  223. }
  224. state.interest.score = whole.value
  225. console.log("whole.value", e, whole.value)
  226. }
  227. </script>
  228. <style>
  229. page {
  230. background-color: #EEF7F7;
  231. padding-bottom: 50rpx;
  232. }
  233. </style>
  234. <style lang="scss" scoped>
  235. /* 点评星级 */
  236. .evaluate-star {
  237. width: 100%;
  238. display: flex;
  239. align-items: center;
  240. .evaluate_title {
  241. font-size: 28rpx;
  242. color: #333333;
  243. padding-right: 20rpx;
  244. }
  245. .star-row {
  246. display: flex;
  247. align-items: center;
  248. .star-box {
  249. width: 48rpx;
  250. height: 48rpx;
  251. margin-right: 16rpx;
  252. .star-img {
  253. width: 100%;
  254. height: 100%;
  255. }
  256. .star-hide {
  257. display: none;
  258. }
  259. }
  260. }
  261. }
  262. .card {
  263. background-color: white;
  264. border-radius: 20rpx;
  265. box-shadow: 0px 0px 6rpx 2rpx rgba(223, 223, 223, 0.3);
  266. margin: 30rpx;
  267. .title {
  268. text-align: center;
  269. font-size: 32rpx;
  270. color: #333333;
  271. padding-bottom: 30rpx;
  272. }
  273. .upload-img {
  274. margin-top: 10rpx;
  275. }
  276. .rate {
  277. .rate-label {
  278. font-size: 28rpx;
  279. color: #333333;
  280. padding-right: 20rpx;
  281. }
  282. }
  283. .input-box {
  284. width: 100%;
  285. border: 1px solid #DCDCDC;
  286. border-radius: 10rpx;
  287. background-color: #F3F3F3;
  288. padding: 30rpx;
  289. box-sizing: border-box;
  290. -moz-box-sizing: border-box;
  291. /*Firefox*/
  292. -webkit-box-sizing: border-box;
  293. /*Safari*/
  294. margin-top: 30rpx;
  295. }
  296. .text-hine {
  297. color: #999999;
  298. font-size: 26rpx;
  299. }
  300. .title1 {
  301. font-size: 30rpx;
  302. color: #333333;
  303. border-bottom: 1px solid #DCDCDC;
  304. padding: 30rpx;
  305. }
  306. .user {
  307. margin-bottom: 40rpx;
  308. .avatar {
  309. width: 140rpx;
  310. height: 160rpx;
  311. background-color: #F3F3F3;
  312. border-radius: 10rpx;
  313. }
  314. .user-info {
  315. margin-left: 40rpx;
  316. margin-top: 28rpx;
  317. .name {
  318. font-size: 28rpx;
  319. color: #333333;
  320. &:last-child {
  321. margin-top: 40rpx;
  322. }
  323. }
  324. }
  325. }
  326. .center {
  327. margin-top: 40rpx;
  328. padding-bottom: 20rpx;
  329. border-bottom: 1rpx solid #DCDCDC;
  330. .tags {
  331. flex-wrap: wrap;
  332. .tag {
  333. border-radius: 28rpx;
  334. background-color: #F3F3F3;
  335. padding: 0rpx 20rpx;
  336. border: 1px solid #DCDCDC;
  337. margin-right: 18rpx;
  338. margin-bottom: 15rpx;
  339. color: #333333;
  340. font-size: 26rpx;
  341. display: flex;
  342. flex-direction: row;
  343. justify-content: center;
  344. align-items: center;
  345. height: 57rpx;
  346. &:last-child {
  347. margin-right: 0rpx;
  348. margin-bottom: 0px;
  349. }
  350. .tag-close {
  351. width: 32rpx;
  352. height: 32rpx;
  353. margin-left: 15rpx;
  354. }
  355. }
  356. }
  357. }
  358. }
  359. .btn {
  360. margin: 60rpx 40rpx 0rpx;
  361. }
  362. .uni-list-cell {
  363. display: flex;
  364. margin: 10rpx auto;
  365. width: 90%;
  366. justify-content: space-between;
  367. align-items: center;
  368. }
  369. </style>