rate.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <view class="one_1">
  5. <image v-if="info.source&&info.source.file.length>0" class="image"
  6. :src="info.source.file&&info.source.file.length>0?info.source.file[0].url:''">
  7. </image>
  8. <image v-else class="image" :src="config.logo_url&&config.logo_url.length>0?config.logo_url[0].url:''">
  9. </image>
  10. <text v-if="info.type=='0'">酒店民宿</text>
  11. <text v-else>景区门票</text>
  12. </view>
  13. <view class="one_2">
  14. <view class="left">
  15. <image v-if="info.source&&info.source.file.length>0" class="image"
  16. :src="info.source.file&&info.source.file.length>0?info.source.file[0].url:''">
  17. </image>
  18. <image v-else class="image"
  19. :src="config.logo_url&&config.logo_url.length>0?config.logo_url[0].url:''">
  20. </image>
  21. </view>
  22. <view class="right">
  23. <view class="right_1">
  24. <view class="left">
  25. <view class="name textOver">{{info.source_name||'暂无'}}</view>
  26. <view class="other">{{info.zhType||'暂无'}}</view>
  27. <view class="other">{{info.zhPerson||'暂无'}}</view>
  28. </view>
  29. <view class="right">
  30. <view class="other">
  31. ¥{{info.source.money||'0'}}
  32. </view>
  33. <view class="other">
  34. ×{{info.num||'0'}}
  35. </view>
  36. </view>
  37. </view>
  38. <view class="right_2">
  39. 合计:¥{{info.money||'0'}}
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="two">
  45. <uni-forms class="form" ref="form" :rules="rules" :modelValue="form" label-position="top" label-width='100'>
  46. <uni-forms-item label="评分(必填)" required name="rate">
  47. <uni-rate v-model="form.rate" />
  48. </uni-forms-item>
  49. <uni-forms-item label="内容(必填)" required name="content">
  50. <uni-easyinput type="textarea" v-model="form.content" placeholder="请输入内容" />
  51. </uni-forms-item>
  52. <uni-forms-item label="上传图片0/3(选填)" name="file">
  53. <upload class='upload' :list="form.file" name="file" :count="3" @uplSuc="uplSuc" @uplDel="uplDel">
  54. </upload>
  55. </uni-forms-item>
  56. </uni-forms>
  57. <button class="button" type="primary" @click="submit('form')">提交</button>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import moment from 'moment';
  63. import upload from '../../components/upload/index.vue';
  64. export default {
  65. components: {
  66. upload
  67. },
  68. data() {
  69. return {
  70. id: '',
  71. config: {
  72. logo_url: []
  73. },
  74. user: {},
  75. info: {
  76. source: {
  77. file: []
  78. }
  79. },
  80. form: {
  81. file: []
  82. },
  83. statusList: [],
  84. personList: [],
  85. typeList: [],
  86. // 校验规则
  87. rules: {
  88. rate: {
  89. rules: [{
  90. required: true,
  91. errorMessage: '请选择评分'
  92. }]
  93. },
  94. content: {
  95. rules: [{
  96. required: true,
  97. errorMessage: '请输入内容'
  98. }]
  99. },
  100. },
  101. }
  102. },
  103. onLoad: async function(e) {
  104. const that = this;
  105. that.$set(that, `id`, e && e.id || '');
  106. that.searchConfig();
  107. that.searchToken();
  108. await that.searchOther();
  109. that.search();
  110. },
  111. methods: {
  112. searchConfig() {
  113. const that = this;
  114. try {
  115. const res = uni.getStorageSync('config');
  116. if (res) that.$set(that, `config`, res);
  117. } catch (e) {
  118. uni.showToast({
  119. title: err.errmsg,
  120. icon: 'error',
  121. duration: 2000
  122. });
  123. }
  124. },
  125. searchToken() {
  126. const that = this;
  127. try {
  128. const res = uni.getStorageSync('token');
  129. if (res) that.$set(that, `user`, res);
  130. } catch (e) {
  131. uni.showToast({
  132. title: err.errmsg,
  133. icon: 'error',
  134. duration: 2000
  135. });
  136. }
  137. },
  138. async search() {
  139. const that = this;
  140. if (that.id) {
  141. const res = await that.$api(`/order/${that.id}`, 'GET', {})
  142. if (res.errcode == '0') {
  143. const status = that.statusList.find(i => i.value == res.data.status)
  144. if (status) res.data.zhStatus = status.label
  145. if (res.data && res.data.source && res.data.source.person) {
  146. const person = that.personList.find(i => i.value == res.data.source.person)
  147. if (person) res.data.zhPerson = person.label
  148. }
  149. if (res.data && res.data.source && res.data.source.type) {
  150. const type = that.typeList.find(i => i.value == res.data.source.type)
  151. if (type) res.data.zhType = type.label
  152. }
  153. that.$set(that, `info`, res.data)
  154. } else {
  155. uni.showToast({
  156. title: res.errmsg,
  157. });
  158. }
  159. }
  160. },
  161. // 图片上传
  162. uplSuc(e) {
  163. const that = this;
  164. that.$set(that.form, `${e.name}`, [...that.form[e.name], e.data]);
  165. },
  166. // 图片删除
  167. uplDel(e) {
  168. const that = this;
  169. let data = that.form[e.name];
  170. let arr = data.filter((i, index) => index != e.data.index);
  171. that.$set(that.form, `${e.name}`, arr)
  172. },
  173. submit(ref) {
  174. const that = this;
  175. that.$refs[ref].validate().then(async data => {
  176. data.user = that.user._id
  177. data.order = that.id
  178. data.source = that.info.source._id
  179. data.type = that.info.type
  180. data.create_time = moment().format('YYYY-MM-DD HH:mm:ss')
  181. const res = await that.$api(`/rateOrder`, 'POST', data);
  182. if (res.errcode == '0') {
  183. const arr = await that.$api(`/order/${that.id}`, 'POST', {
  184. status: "7"
  185. })
  186. if (arr.errcode == '0') {
  187. uni.showToast({
  188. title: '评价成功',
  189. icon: 'none'
  190. })
  191. uni.navigateBack({
  192. delta: 1
  193. })
  194. } else {
  195. uni.showToast({
  196. title: res.errmsg,
  197. });
  198. }
  199. } else {
  200. uni.showToast({
  201. title: res.errmsg,
  202. icon: 'none'
  203. })
  204. }
  205. }).catch(err => {
  206. console.log('err', err);
  207. })
  208. },
  209. // 查询其他信息
  210. async searchOther() {
  211. const that = this;
  212. let res;
  213. // 查询类型
  214. res = await that.$api(`/dictData`, 'GET', {
  215. type: 'order_status',
  216. is_use: '0',
  217. })
  218. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  219. // 出游人群
  220. res = await that.$api(`/dictData`, 'GET', {
  221. type: 'ticket_person',
  222. is_use: '0',
  223. })
  224. if (res.errcode == '0') that.$set(that, `personList`, res.data);
  225. // 服务特色
  226. res = await that.$api(`/dictData`, 'GET', {
  227. type: 'ticket_type',
  228. is_use: '0',
  229. })
  230. if (res.errcode == '0') that.$set(that, `typeList`, res.data);
  231. },
  232. }
  233. }
  234. </script>
  235. <style lang="scss" scoped>
  236. .main {
  237. .one {
  238. background-color: var(--mainColor);
  239. border-radius: 5px;
  240. margin: 2vw 2vw 0 2vw;
  241. padding: 2vw;
  242. border: 1px solid #d5d5da;
  243. .one_1 {
  244. display: flex;
  245. align-items: center;
  246. .image {
  247. width: 8vw;
  248. height: 8vw;
  249. border-radius: 8vw;
  250. }
  251. text {
  252. padding: 0 0 0 2vw;
  253. }
  254. }
  255. .one_2 {
  256. display: flex;
  257. justify-content: space-between;
  258. margin: 2vw 0 0 0;
  259. padding: 0 2vw;
  260. .left {
  261. width: 20vw;
  262. .image {
  263. width: 20vw;
  264. height: 20vw;
  265. border-radius: 1vw;
  266. }
  267. }
  268. .right {
  269. width: 65vw;
  270. margin: 0 0 0 2vw;
  271. .right_1 {
  272. display: flex;
  273. justify-content: space-between;
  274. .left {
  275. width: 55vw;
  276. .name {
  277. font-size: var(--font14Size);
  278. }
  279. .other {
  280. padding: 2px 0 0 0;
  281. font-size: var(--font12Size);
  282. color: var(--f85Color);
  283. }
  284. }
  285. .right {
  286. width: 10vw;
  287. text-align: right;
  288. .other {
  289. padding: 2px 0 0 0;
  290. font-size: var(--font12Size);
  291. color: var(--f85Color);
  292. }
  293. }
  294. }
  295. .right_2 {
  296. text-align: right;
  297. font-size: var(--font12Size);
  298. }
  299. }
  300. }
  301. }
  302. .two {
  303. padding: 2vw;
  304. .form-item {
  305. display: flex;
  306. align-items: center;
  307. }
  308. .button {
  309. background-color: var(--f3CColor);
  310. }
  311. }
  312. }
  313. </style>