user-orderaftersale.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view>
  3. <!-- 导航 -->
  4. <view class="nav-base bg-white">
  5. <block v-for="(item, index) in nav_status_list" :key="index">
  6. <view v-if="nav_status_index == index" class="item fl tc cr-main" :data-index="index" @tap="nav_event">{{item.name}}</view>
  7. <view v-else class="item fl tc" :data-index="index" @tap="nav_event">{{item.name}}</view>
  8. </block>
  9. </view>
  10. <!-- 订单列表 -->
  11. <scroll-view :scroll-y="true" class="scroll-box scroll-box-ece-nav" @scrolltolower="scroll_lower" lower-threshold="60">
  12. <view v-if="data_list.length > 0" class="padding-horizontal-main padding-top-main">
  13. <view v-for="(item, index) in data_list" :key="index" class="list-item padding-horizontal-main padding-top-main border-radius-main bg-white oh spacing-mb">
  14. <view class="item-base oh br-b padding-bottom-main">
  15. <text class="cr-base">{{item.add_time}}</text>
  16. <text class="fr cr-red">{{item.status_text}}</text>
  17. </view>
  18. <view class="goods-item oh">
  19. <navigator :url="'/pages/user-orderaftersale-detail/user-orderaftersale-detail?oid=' + item.order_id + '&did=' + item.order_detail_id" hover-class="none">
  20. <image class="goods-image fl radius" :src="item.order_data.items.images" mode="aspectFill"></image>
  21. <view class="goods-base pr">
  22. <view class="multi-text">{{item.order_data.items.title}}</view>
  23. <view v-if="item.order_data.items.spec != null" class="margin-top-sm">
  24. <block v-for="(sv, si) in item.order_data.items.spec" :key="si">
  25. <text v-if="si > 0" class="cr-grey padding-left-xs padding-right-xs">;</text>
  26. <text class="cr-gray">{{sv.value}}</text>
  27. </block>
  28. </view>
  29. <view class="margin-top-sm">
  30. <text class="fw-b">{{item.order_data.currency_data.currency_symbol}}{{item.order_data.items.price}}</text>
  31. <text class="margin-left-sm">x{{item.order_data.items.buy_number}}</text>
  32. </view>
  33. </view>
  34. </navigator>
  35. </view>
  36. <view class="item-describe padding-vertical-main">
  37. <text class="cr-base">{{item.type_text}}</text>
  38. <text class="cr-grey margin-left-sm margin-right-sm">/</text>
  39. <text class="cr-base">{{item.reason}}</text>
  40. <block v-if="item.price > 0">
  41. <text class="cr-grey margin-left-sm margin-right-sm">/</text>
  42. <text class="sales-price text-size-sm">{{item.order_data.currency_data.currency_symbol}}{{item.price}}</text>
  43. </block>
  44. <block v-if="item.number > 0">
  45. <text class="cr-grey margin-left-sm margin-right-sm">/</text>
  46. <text class="cr-main fw-b">{{item.number}}</text>
  47. </block>
  48. </view>
  49. <view v-if="item.status <= 2 || item.status == 4" class="item-operation tr br-t padding-vertical-main">
  50. <button v-if="item.status != 3 && item.status != 5" class="br-yellow cr-yellow bg-white round" type="default" size="mini" @tap="cancel_event" :data-value="item.id" :data-index="index" hover-class="none">取消</button>
  51. <button v-if="item.status == 1 && item.type == 1" class="br-green cr-green bg-white round" type="default" size="mini" @tap="delivery_event" :data-oid="item.order_id" :data-did="item.order_detail_id" :data-index="index" hover-class="none">退货</button>
  52. </view>
  53. </view>
  54. </view>
  55. <view v-else>
  56. <!-- 提示信息 -->
  57. <component-no-data :propStatus="data_list_loding_status" :propMsg="data_list_loding_msg"></component-no-data>
  58. </view>
  59. <!-- 结尾 -->
  60. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  61. </scroll-view>
  62. </view>
  63. </template>
  64. <script>
  65. const app = getApp();
  66. import componentNoData from "../../components/no-data/no-data";
  67. import componentBottomLine from "../../components/bottom-line/bottom-line";
  68. export default {
  69. data() {
  70. return {
  71. params: null,
  72. data_list_loding_status: 1,
  73. data_list_loding_msg: '',
  74. data_bottom_line_status: false,
  75. // 接口数据
  76. data_list: [],
  77. data_total: 0,
  78. data_page_total: 0,
  79. data_page: 1,
  80. form_keyword_value: '',
  81. // 导航
  82. // 状态(0待确认, 1待退货, 2待审核, 3已完成, 4已拒绝, 5已取消)
  83. nav_status_list: [
  84. { name: "全部", value: "-1" },
  85. { name: "待确认", value: "0" },
  86. { name: "待退货", value: "1" },
  87. { name: "待审核", value: "2" },
  88. { name: "已完成", value: "3" },
  89. { name: "已拒绝", value: "4" },
  90. { name: "已取消", value: "5" },
  91. ],
  92. nav_status_index: 0
  93. };
  94. },
  95. components: {
  96. componentNoData,
  97. componentBottomLine
  98. },
  99. props: {},
  100. onLoad(params) {
  101. // 是否指定状态
  102. var nav_status_index = 0;
  103. if ((params.status || null) != null) {
  104. for (var i in this.nav_status_list) {
  105. if (this.nav_status_list[i]['value'] == params.status) {
  106. nav_status_index = i;
  107. break;
  108. }
  109. }
  110. }
  111. this.setData({
  112. params: params,
  113. form_keyword_value: params.keywords || '',
  114. nav_status_index: nav_status_index
  115. });
  116. },
  117. onShow() {
  118. // 数据加载
  119. this.init();
  120. // 分享菜单处理
  121. app.globalData.page_share_handle();
  122. },
  123. // 下拉刷新
  124. onPullDownRefresh() {
  125. this.setData({
  126. data_page: 1
  127. });
  128. this.get_data_list(1);
  129. },
  130. methods: {
  131. // 获取数据
  132. init() {
  133. var user = app.globalData.get_user_info(this, "init");
  134. if (user != false) {
  135. // 用户未绑定用户则转到登录页面
  136. if (app.globalData.user_is_need_login(user)) {
  137. uni.redirectTo({
  138. url: "/pages/login/login?event_callback=init"
  139. });
  140. return false;
  141. } else {
  142. // 获取数据
  143. this.get_data_list();
  144. }
  145. } else {
  146. this.setData({
  147. data_list_loding_status: 0,
  148. data_bottom_line_status: false
  149. });
  150. }
  151. },
  152. // 获取数据
  153. get_data_list(is_mandatory) {
  154. // 分页是否还有数据
  155. if ((is_mandatory || 0) == 0) {
  156. if (this.data_bottom_line_status == true) {
  157. uni.stopPullDownRefresh();
  158. return false;
  159. }
  160. }
  161. // 加载loding
  162. uni.showLoading({
  163. title: '加载中...'
  164. });
  165. this.setData({
  166. data_list_loding_status: 1
  167. });
  168. // 参数
  169. var status = (this.nav_status_list[this.nav_status_index] || null) == null ? -1 : this.nav_status_list[this.nav_status_index]['value'];
  170. uni.request({
  171. url: app.globalData.get_request_url("index", "orderaftersale"),
  172. method: 'POST',
  173. data: {
  174. page: this.data_page,
  175. keywords: this.form_keyword_value || "",
  176. status: status,
  177. is_more: 1
  178. },
  179. dataType: 'json',
  180. success: res => {
  181. uni.hideLoading();
  182. uni.stopPullDownRefresh();
  183. if (res.data.code == 0) {
  184. if (res.data.data.data.length > 0) {
  185. if (this.data_page <= 1) {
  186. var temp_data_list = res.data.data.data;
  187. } else {
  188. var temp_data_list = this.data_list || [];
  189. var temp_data = res.data.data.data;
  190. for (var i in temp_data) {
  191. temp_data_list.push(temp_data[i]);
  192. }
  193. }
  194. this.setData({
  195. data_list: temp_data_list,
  196. data_total: res.data.data.total,
  197. data_page_total: res.data.data.page_total,
  198. data_list_loding_status: 3,
  199. data_page: this.data_page + 1
  200. });
  201. // 是否还有数据
  202. this.setData({
  203. data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
  204. });
  205. } else {
  206. this.setData({
  207. data_list_loding_status: 0,
  208. data_list_loding_msg: '没有相关数据',
  209. data_list: [],
  210. data_bottom_line_status: false
  211. });
  212. }
  213. } else {
  214. this.setData({
  215. data_list_loding_status: 0,
  216. data_list_loding_msg: res.data.msg
  217. });
  218. if (app.globalData.is_login_check(res.data, this, 'get_data_list')) {
  219. app.globalData.showToast(res.data.msg);
  220. }
  221. }
  222. },
  223. fail: () => {
  224. uni.hideLoading();
  225. uni.stopPullDownRefresh();
  226. this.setData({
  227. data_list_loding_status: 2,
  228. data_list_loding_msg: '服务器请求出错'
  229. });
  230. app.globalData.showToast('服务器请求出错');
  231. }
  232. });
  233. },
  234. // 滚动加载
  235. scroll_lower(e) {
  236. this.get_data_list();
  237. },
  238. // 导航事件
  239. nav_event(e) {
  240. this.setData({
  241. nav_status_index: e.currentTarget.dataset.index || 0,
  242. data_page: 1
  243. });
  244. this.get_data_list(1);
  245. },
  246. // 输入框事件
  247. input_event(e) {
  248. this.setData({
  249. form_keyword_value: e.detail.value
  250. });
  251. },
  252. // 取消
  253. cancel_event(e) {
  254. uni.showModal({
  255. title: '温馨提示',
  256. content: '取消后不可恢复,确定继续吗?',
  257. confirmText: '确认',
  258. cancelText: '不了',
  259. success: result => {
  260. if (result.confirm) {
  261. // 参数
  262. var id = e.currentTarget.dataset.value;
  263. var index = e.currentTarget.dataset.index;
  264. // 加载loding
  265. uni.showLoading({
  266. title: '处理中...'
  267. });
  268. uni.request({
  269. url: app.globalData.get_request_url("cancel", "orderaftersale"),
  270. method: 'POST',
  271. data: {
  272. id: id
  273. },
  274. dataType: 'json',
  275. success: res => {
  276. uni.hideLoading();
  277. if (res.data.code == 0) {
  278. var temp_data_list = this.data_list;
  279. temp_data_list[index]['status'] = 5;
  280. temp_data_list[index]['status_text'] = '已取消';
  281. this.setData({
  282. data_list: temp_data_list
  283. });
  284. app.globalData.showToast(res.data.msg, 'success');
  285. } else {
  286. if (app.globalData.is_login_check(res.data)) {
  287. app.globalData.showToast(res.data.msg);
  288. } else {
  289. app.globalData.showToast('提交失败,请重试!');
  290. }
  291. }
  292. },
  293. fail: () => {
  294. uni.hideLoading();
  295. app.globalData.showToast('服务器请求出错');
  296. }
  297. });
  298. }
  299. }
  300. });
  301. },
  302. // 退货
  303. delivery_event(e) {
  304. var oid = e.currentTarget.dataset.oid || 0;
  305. var did = e.currentTarget.dataset.did || 0;
  306. if (oid == 0 || did == 0) {
  307. app.globalData.showToast("参数有误");
  308. return false;
  309. }
  310. // 进入售后页面
  311. uni.navigateTo({
  312. url: "/pages/user-orderaftersale-detail/user-orderaftersale-detail?oid=" + oid + "&did=" + did + "&is_delivery_popup=1"
  313. });
  314. }
  315. }
  316. };
  317. </script>
  318. <style>
  319. @import './user-orderaftersale.css';
  320. </style>