speakShopInfo.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view>
  3. <view>
  4. <u-navbar :back-text="i18n('Back')" :back-text-style="backStyle" back-icon-color="#fff" title-color="#fff"
  5. :background="background" title-width="300" :title="i18n('speakShopInfo')"></u-navbar>
  6. </view>
  7. <view class="user-speak">
  8. <view class="speak-title">
  9. <view class="speak-num">{{$i18n.locale=='zh'?'礼品评分':'Commodity grade'}}</view>
  10. <view class="speak-stars">
  11. <u-rate :count="count" v-model="value"></u-rate>
  12. </view>
  13. </view>
  14. <view class="speak-text">
  15. <textarea v-if="$i18n.locale=='zh'" class="speak-thing" maxlength="500"
  16. placeholder="宝贝满足你的期待吗?说说你的使用体验,分享给想买的人吧!" @input="sumfontnum"></textarea>
  17. <textarea v-else class="speak-thing" maxlength="500"
  18. placeholder="Baby meet your expectations? Talk about your experience and share it with anyone who wants to buy it!"
  19. @input="sumfontnum"></textarea>
  20. <view class="speak-much"><text>{{fontNum}}</text>/500</view>
  21. <view class="speak-name">
  22. <view class="name-none">{{$i18n.locale=='zh'?'匿名评价':'Anonymous evaluation'}}</view>
  23. <view class="speak-switch">
  24. <!-- <switch @change="switch1Change" style="transform:scale(0.8)" :value='true'></switch> -->
  25. <u-switch v-model="checked" class="ui-checked"></u-switch>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- <view class="user-pic">
  31. <view class="pic-title">{{$i18n.locale=='zh'?'上传图片(最多9张)':'Upload images (maximum 9)'}}</view>
  32. <u-upload class="pic-num" :action="action" ref="uUpload" max-count="9" :auto-upload="false"></u-upload>
  33. </view> -->
  34. <view class="speak-update">
  35. <button class="speak-btn" @tap="toSubmit">{{$i18n.locale=='zh'?'提交评价':'Submit'}}</button>
  36. </view>
  37. <!-- 提示信息弹窗 -->
  38. <uni-popup ref="message">
  39. <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
  40. </uni-popup>
  41. </view>
  42. </template>
  43. <script>
  44. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  45. import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
  46. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  47. import {
  48. getToken
  49. } from '@/api/token'
  50. import {
  51. orderReview
  52. } from '@/api/address'
  53. export default {
  54. components: {
  55. uniPopupDialog,
  56. uniPopupMessage,
  57. uniPopup
  58. },
  59. data() {
  60. return {
  61. checked: true,
  62. background: {
  63. backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
  64. },
  65. backStyle: {
  66. color: '#FFFFFF',
  67. },
  68. fontNum: 0,
  69. count: 5,
  70. value: 0,
  71. // action: '',
  72. orderId: null,
  73. shopId: null,
  74. evaluate: null,
  75. msgType: 'success',
  76. messageText: '请稍后...',
  77. }
  78. },
  79. onLoad(option) {
  80. console.log(option, '====');
  81. this.orderId = option.orderId;
  82. this.shopId = option.shopId
  83. },
  84. methods: {
  85. i18n(data) {
  86. return this.$t('common.' + data);
  87. },
  88. change(e) {
  89. console.log('当前模式:' + e.type + ',状态:' + e.show);
  90. },
  91. sumfontnum(e) {
  92. this.evaluate = e
  93. this.fontNum = this.evaluate.detail.value.length
  94. },
  95. switch1Change: function(e) {
  96. console.log('switch1 发生 change 事件,携带值为', e.detail.value)
  97. },
  98. // 提交
  99. async toSubmit() {
  100. if (this.fontNum > 0) {
  101. let params = {
  102. commodityId: this.orderId,
  103. orderId: this.shopId,
  104. comment: this.evaluate.detail.value,
  105. commodityMark: this.value,
  106. }
  107. const tokendata = await this.$myRequest({
  108. url: '/sys/token',
  109. method: 'get'
  110. });
  111. let demo = params
  112. console.log(demo);
  113. orderReview(demo, tokendata.data).then((res) => {
  114. console.log(res.msg);
  115. if (this.$i18n.locale == 'zh') {
  116. this.msgType = 'success'
  117. this.messageText = '评论成功'
  118. this.$refs.message.open()
  119. } else {
  120. this.msgType = 'success'
  121. this.messageText = 'Comment on success'
  122. this.$refs.message.open()
  123. }
  124. setTimeout(() => {
  125. uni.navigateTo({
  126. url: './myPayList'
  127. })
  128. }, 1500)
  129. }).catch(error => {
  130. if (this.$i18n.locale == 'zh') {
  131. this.msgType = 'error'
  132. this.messageText = '提交失败'
  133. this.$refs.message.open()
  134. } else {
  135. this.msgType = 'error'
  136. this.messageText = 'Submit failure'
  137. this.$refs.message.open()
  138. }
  139. })
  140. } else {
  141. if (this.$i18n.locale == 'zh') {
  142. this.msgType = 'error'
  143. this.messageText = '请留下您对礼品的评价'
  144. } else {
  145. this.msgType = 'error'
  146. this.messageText = 'Please leave a comment on the gift'
  147. }
  148. this.$refs.message.open()
  149. }
  150. },
  151. },
  152. }
  153. </script>
  154. <style lang="scss" scoped>
  155. .user-speak {
  156. .speak-title {
  157. margin-top: 20rpx;
  158. display: flex;
  159. width: 100%;
  160. background-color: #fff;
  161. height: 100rpx;
  162. .speak-num {
  163. margin-left: 5%;
  164. height: 100rpx;
  165. line-height: 100rpx;
  166. }
  167. .speak-stars {
  168. height: 100rpx;
  169. line-height: 100rpx;
  170. }
  171. }
  172. .speak-text {
  173. width: 100%;
  174. background-color: #fff;
  175. .speak-thing {
  176. border: 1rpx solid #878787;
  177. width: 94%;
  178. height: 400rpx;
  179. margin-left: 3%;
  180. border-radius: 20rpx;
  181. padding: 10rpx;
  182. text-indent: 64rpx;
  183. }
  184. .speak-much {
  185. margin-left: 80%;
  186. height: 40rpx;
  187. line-height: 40rpx;
  188. font-size: 16px;
  189. color: #9999a6;
  190. }
  191. .speak-name {
  192. width: 88%;
  193. margin-left: 6%;
  194. height: 80rpx;
  195. display: flex;
  196. .name-none {
  197. height: 80rpx;
  198. line-height: 80rpx;
  199. font-size: 30rpx;
  200. }
  201. .speak-switch {
  202. height: 80rpx;
  203. line-height: 50rpx;
  204. margin-left: 20rpx;
  205. margin-top: 12rpx;
  206. }
  207. }
  208. }
  209. }
  210. .user-pic {
  211. width: 100%;
  212. margin-top: 20rpx;
  213. background-color: #fff;
  214. .pic-title {
  215. width: 88%;
  216. margin-left: 6%;
  217. height: 80rpx;
  218. line-height: 80rpx;
  219. font-size: 30rpx;
  220. font-weight: 700;
  221. }
  222. .pic-num {
  223. width: 90%;
  224. margin-left: 5%;
  225. }
  226. }
  227. .speak-update {
  228. width: 100%;
  229. height: 150rpx;
  230. background-color: #fff;
  231. margin-top: 10rpx;
  232. padding: 45rpx 0;
  233. .speak-btn {
  234. height: 60rpx;
  235. line-height: 60rpx;
  236. width: 200rpx;
  237. border-radius: 50rpx;
  238. background-color: #1777FEFF;
  239. color: #fff;
  240. margin-left: 70%;
  241. }
  242. }
  243. </style>