user-order.vue 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989
  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. <!-- 选择 -->
  16. <view v-if="nav_status_index == 1 && home_is_enable_order_bulk_pay == 1" @tap="selected_event" :data-oid="item.id" class="fl selected">
  17. <image class="icon va-m" :src="common_static_url+'select' + (order_select_ids.indexOf(item.id) != -1 ? '-active' : '') + '-icon.png'" mode="widthFix"></image>
  18. </view>
  19. <!-- 基础信息 -->
  20. <view class="fl cp" @tap="url_event" :data-value="item.warehouse_url || ''">
  21. <image v-if="(item.warehouse_icon || null) != null" class="warehouse-group-icon va-m margin-right-sm" :src="item.warehouse_icon" mode="aspectFit"></image>
  22. <text class="cr-base va-m">{{item.warehouse_name}}</text>
  23. </view>
  24. <text class="fr cr-red">{{item.status_name}}<text v-if="(item.is_under_line_text || null) != null">({{item.is_under_line_text}})</text></text>
  25. </view>
  26. <view v-for="(detail, di) in item.items" :key="di" class="br-b-dashed oh padding-vertical-main">
  27. <view :data-value="'/pages/user-order-detail/user-order-detail?id=' + item.id" @tap="url_event">
  28. <image class="goods-image fl radius" :src="detail.images" mode="aspectFill"></image>
  29. <view class="goods-base pr">
  30. <view class="multi-text">{{detail.title}}</view>
  31. <view v-if="detail.spec != null" class="margin-top-sm">
  32. <block v-for="(sv, si) in detail.spec" :key="si">
  33. <text v-if="si > 0" class="cr-grey padding-left-xs padding-right-xs">;</text>
  34. <text class="cr-gray">{{sv.value}}</text>
  35. </block>
  36. </view>
  37. <view class="margin-top-sm">
  38. <text class="fw-b">{{item.currency_data.currency_symbol}}{{detail.price}}</text>
  39. <text class="margin-left-sm">x{{detail.buy_number}}</text>
  40. </view>
  41. <view v-if="item.is_can_launch_aftersale == 1 && (detail.orderaftersale_btn_text || null) != null" class="orderaftersale-btn-text cr-blue pa bg-white" @tap.stop="orderaftersale_event" :data-oid="item.id" :data-did="detail.id">{{detail.orderaftersale_btn_text}}</view>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="padding-vertical-main tr cr-base text-size">
  46. <text>共<text class="fw-b">{{item.buy_number_count}}</text>件 合计 <text class="sales-price margin-right-xs">{{item.currency_data.currency_symbol}}{{item.total_price}}</text>元</text>
  47. </view>
  48. <view v-if="item.operate_data.is_cancel + item.operate_data.is_pay + item.operate_data.is_collect + item.operate_data.is_comments + item.operate_data.is_delete+(item.plugins_is_order_allot_button || 0)+(item.plugins_is_order_batch_button || 0)+(item.plugins_is_order_frequencycard_button || 0) > 0 || (item.status == 2 && item.order_model != 2) || ((item.plugins_express_data || 0) == 1 && (item.express_number || null) != null)" class="item-operation tr br-t padding-vertical-main">
  49. <button v-if="item.operate_data.is_cancel == 1" class="round bg-white cr-yellow br-yellow" type="default" size="mini" @tap="cancel_event" :data-value="item.id" :data-index="index" hover-class="none">取消</button>
  50. <button v-if="item.operate_data.is_pay == 1" class="round bg-white cr-green br-green" type="default" size="mini" @tap="pay_event" :data-value="item.id" :data-index="index" hover-class="none">支付</button>
  51. <button v-if="item.operate_data.is_collect == 1" class="round bg-white cr-green br-green" type="default" size="mini" @tap="collect_event" :data-value="item.id" :data-index="index" hover-class="none">收货</button>
  52. <button v-if="(item.plugins_express_data || 0) == 1 && (item.express_number || null) != null" class="round bg-white cr-main br-main" type="default" size="mini" @tap="url_event" :data-value="'/pages/plugins/express/detail/detail?id='+item.id" hover-class="none">物流</button>
  53. <button v-if="item.operate_data.is_comments == 1" class="round bg-white cr-green br-green" type="default" size="mini" @tap="comments_event" :data-value="item.id" :data-index="index" hover-class="none">评论</button>
  54. <button v-if="item.status == 2 && item.order_model != 2" class="round cr-base br" type="default" size="mini" @tap="rush_event" :data-value="item.id" :data-index="index" hover-class="none">催催</button>
  55. <button v-if="item.operate_data.is_delete == 1" class="round bg-white cr-red br-red" type="default" size="mini" @tap="delete_event" :data-value="item.id" :data-index="index" hover-class="none">删除</button>
  56. <button v-if="(item.plugins_is_order_allot_button || 0) == 1" class="round bg-white cr-main br-main" type="default" size="mini" @tap="url_event" :data-value="'/pages/plugins/realstore/orderallot-list/orderallot-list?oid='+item.id" hover-class="none">子单</button>
  57. <button v-if="(item.plugins_is_order_batch_button || 0) == 1" class="round bg-white cr-blue br-blue" type="default" size="mini" @tap="url_event" :data-value="'/pages/plugins/realstore/batchorder-list/batchorder-list?oid='+item.id" hover-class="none">批次</button>
  58. <button v-if="(item.plugins_is_order_frequencycard_button || 0) == 1" class="round bg-white cr-green br-green" type="default" size="mini" @tap="url_event" :data-value="'/pages/plugins/realstore/frequencycard-list/frequencycard-list?oid='+item.id" hover-class="none">次卡</button>
  59. </view>
  60. </view>
  61. </view>
  62. <view v-else>
  63. <!-- 提示信息 -->
  64. <component-no-data :propStatus="data_list_loding_status"></component-no-data>
  65. </view>
  66. <!-- 结尾 -->
  67. <component-bottom-line :propStatus="data_bottom_line_status"></component-bottom-line>
  68. </scroll-view>
  69. <!-- 合并支付 -->
  70. <view v-if="nav_status_index == 1 && order_select_ids.length > 0 && home_is_enable_order_bulk_pay == 1">
  71. <button class="bottom-fixed pay-merge-submit bg-green cr-white round" type="default" size="mini" hover-class="none" @tap="pay_merge_event">合并支付</button>
  72. </view>
  73. <!-- 支付二维码展示 -->
  74. <component-popup :propShow="popup_view_pay_qrcode_is_show" propPosition="bottom" @onclose="popup_view_pay_qrcode_event_close">
  75. <view class="padding-top-xxxl padding-bottom-xxxl padding-left-xxxl padding-right-xxxl tc">
  76. <block v-if="(popup_view_pay_data || null) == null || (popup_view_pay_data.qrcode_url || null) == null || (popup_view_pay_data.name || null) == null || (popup_view_pay_data.check_url || null) == null || (popup_view_pay_data.order_no || null) == null">
  77. <text class="cr-gray">无支付信息</text>
  78. </block>
  79. <block v-else>
  80. <view class="fw-b text-size cr-base margin-bottom-sm">{{popup_view_pay_data.name}}</view>
  81. <image :src="popup_view_pay_data.qrcode_url" mode="aspectFit" class="dis-block auto max-w"></image>
  82. <view v-if="(popup_view_pay_data.msg || null) != null" class="cr-yellow margin-top-sm">{{popup_view_pay_data.msg}}</view>
  83. <!-- #ifdef H5 -->
  84. <view v-if="(popup_view_pay_data.pay_url) != null" class="margin-top-xl">
  85. <a :href="popup_view_pay_data.pay_url" target="_blank" class="dis-inline-block cr-green">尝试点击去支付</a>
  86. </view>
  87. <!-- #endif -->
  88. </block>
  89. </view>
  90. </component-popup>
  91. <!-- 支付html展示 -->
  92. <component-popup :propShow="popup_view_pay_html_is_show" propPosition="bottom" @onclose="popup_view_pay_html_event_close">
  93. <view class="popup-pay-html-content padding-top-xxxl padding-bottom-xxxl padding-left-xxxl padding-right-xxxl tc">
  94. <block v-if="(popup_view_pay_data || null) == null">
  95. <text class="cr-gray">无支付信息</text>
  96. </block>
  97. <block v-else>
  98. <mp-html :content="popup_view_pay_data" />
  99. </block>
  100. </view>
  101. </component-popup>
  102. <!-- 支付方式 popup -->
  103. <component-popup :propShow="is_show_payment_popup" propPosition="bottom" @onclose="payment_popup_event_close">
  104. <view v-if="payment_list.length > 0" class="payment-list oh bg-base padding-main">
  105. <view class="padding-top-main padding-left-main">
  106. <view v-for="(item, index) in payment_list" :key="index" class="item tc fl">
  107. <view class="item-content bg-white border-radius-main margin-right-main margin-bottom-main" :data-value="item.id" :data-type="item.payment" @tap="popup_payment_event">
  108. <image v-if="(item.logo || null) != null" class="icon va-m margin-right-sm" :src="item.logo" mode="widthFix"></image>
  109. <text class="va-m">{{item.name}}</text>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. <view v-else class="padding-top-xxxl padding-bottom-xxxl oh bg-white tc cr-gray">没有支付方式</view>
  115. </component-popup>
  116. </view>
  117. </template>
  118. <script>
  119. const app = getApp();
  120. import base64 from '../../common/js/lib/base64.js';
  121. import componentPopup from "../../components/popup/popup";
  122. import componentNoData from "../../components/no-data/no-data";
  123. import componentBottomLine from "../../components/bottom-line/bottom-line";
  124. var common_static_url = app.globalData.get_static_url('common');
  125. export default {
  126. data() {
  127. return {
  128. common_static_url: common_static_url,
  129. data_list: [],
  130. data_total: 0,
  131. data_page_total: 0,
  132. data_page: 1,
  133. data_list_loding_status: 1,
  134. data_bottom_line_status: false,
  135. params: null,
  136. input_keyword_value: '',
  137. load_status: 0,
  138. is_show_payment_popup: false,
  139. payment_list: [],
  140. payment_id: 0,
  141. payment_type: '',
  142. temp_pay_value: '',
  143. nav_status_list: [
  144. { name: "全部", value: "-1" },
  145. { name: "待付款", value: "1" },
  146. { name: "待发货", value: "2" },
  147. { name: "待收货", value: "3" },
  148. { name: "已完成", value: "4" },
  149. { name: "已失效", value: "5,6" },
  150. ],
  151. nav_status_index: 0,
  152. order_select_ids: [],
  153. // 支付信息
  154. popup_view_pay_html_is_show: false,
  155. popup_view_pay_qrcode_is_show: false,
  156. popup_view_pay_data: null,
  157. popup_view_pay_timer: null,
  158. // 基础配置
  159. home_is_enable_order_bulk_pay: 0
  160. };
  161. },
  162. components: {
  163. componentPopup,
  164. componentNoData,
  165. componentBottomLine
  166. },
  167. props: {},
  168. onLoad(params) {
  169. // 是否指定状态
  170. var nav_status_index = 0;
  171. if ((params.status || null) != null) {
  172. for (var i in this.nav_status_list) {
  173. if (this.nav_status_list[i]['value'] == params.status) {
  174. nav_status_index = i;
  175. break;
  176. }
  177. }
  178. }
  179. this.setData({
  180. params: params,
  181. nav_status_index: nav_status_index
  182. });
  183. },
  184. onShow() {
  185. // 数据加载
  186. this.init();
  187. // 初始化配置
  188. this.init_config();
  189. // 分享菜单处理
  190. app.globalData.page_share_handle();
  191. },
  192. // 下拉刷新
  193. onPullDownRefresh() {
  194. this.setData({
  195. data_page: 1
  196. });
  197. this.get_data_list(1);
  198. },
  199. methods: {
  200. // 初始化配置
  201. init_config(status) {
  202. if ((status || false) == true) {
  203. this.setData({
  204. home_is_enable_order_bulk_pay: app.globalData.get_config('config.home_is_enable_order_bulk_pay')
  205. });
  206. } else {
  207. app.globalData.is_config(this, 'init_config');
  208. }
  209. },
  210. // 获取数据
  211. init() {
  212. var user = app.globalData.get_user_info(this, 'init');
  213. if (user != false) {
  214. // 用户未绑定用户则转到登录页面
  215. if (app.globalData.user_is_need_login(user)) {
  216. uni.redirectTo({
  217. url: "/pages/login/login?event_callback=init"
  218. });
  219. return false;
  220. } else {
  221. // 获取数据
  222. this.get_data_list();
  223. }
  224. } else {
  225. this.setData({
  226. data_list_loding_status: 0,
  227. data_bottom_line_status: false
  228. });
  229. }
  230. },
  231. // 输入框事件
  232. input_event(e) {
  233. this.setData({
  234. input_keyword_value: e.detail.value
  235. });
  236. },
  237. // 获取数据
  238. get_data_list(is_mandatory) {
  239. // 分页是否还有数据
  240. if ((is_mandatory || 0) == 0) {
  241. if (this.data_bottom_line_status == true) {
  242. uni.stopPullDownRefresh();
  243. return false;
  244. }
  245. }
  246. // 加载loding
  247. uni.showLoading({
  248. title: '加载中...'
  249. });
  250. this.setData({
  251. data_list_loding_status: 1
  252. });
  253. // 参数
  254. var order_status = (this.nav_status_list[this.nav_status_index] || null) == null ? -1 : this.nav_status_list[this.nav_status_index]['value'];
  255. // 获取数据
  256. uni.request({
  257. url: app.globalData.get_request_url("index", "order"),
  258. method: 'POST',
  259. data: {
  260. page: this.data_page,
  261. keywords: this.input_keyword_value || "",
  262. status: order_status,
  263. is_more: 1
  264. },
  265. dataType: 'json',
  266. success: res => {
  267. uni.hideLoading();
  268. uni.stopPullDownRefresh();
  269. if (res.data.code == 0) {
  270. if (res.data.data.data.length > 0) {
  271. if (this.data_page <= 1) {
  272. var temp_data_list = res.data.data.data;
  273. } else {
  274. var temp_data_list = this.data_list || [];
  275. var temp_data = res.data.data.data;
  276. for (var i in temp_data) {
  277. temp_data_list.push(temp_data[i]);
  278. }
  279. }
  280. var temp_load_status = this.load_status;
  281. this.setData({
  282. data_list: temp_data_list,
  283. data_total: res.data.data.total,
  284. data_page_total: res.data.data.page_total,
  285. data_list_loding_status: 3,
  286. data_page: this.data_page + 1,
  287. load_status: 1,
  288. payment_list: res.data.data.payment_list || []
  289. });
  290. // 下订单支付处理
  291. if (temp_load_status == 0) {
  292. var ck = app.globalData.data.cache_page_pay_key;
  293. var pay_data = uni.getStorageSync(ck) || null;
  294. if (pay_data != null) {
  295. uni.removeStorageSync(ck);
  296. this.setData({payment_id: parseInt(pay_data.payment_id || 0)});
  297. this.pay_handle(pay_data.order_ids);
  298. }
  299. }
  300. // 是否还有数据
  301. this.setData({
  302. data_bottom_line_status: (this.data_page > 1 && this.data_page > this.data_page_total)
  303. });
  304. } else {
  305. this.setData({
  306. data_list_loding_status: 0,
  307. load_status: 1,
  308. data_list: [],
  309. data_bottom_line_status: false
  310. });
  311. }
  312. } else {
  313. this.setData({
  314. data_list_loding_status: 0,
  315. load_status: 1
  316. });
  317. if (app.globalData.is_login_check(res.data, this, 'get_data_list')) {
  318. app.globalData.showToast(res.data.msg);
  319. }
  320. }
  321. },
  322. fail: () => {
  323. uni.hideLoading();
  324. uni.stopPullDownRefresh();
  325. this.setData({
  326. data_list_loding_status: 2,
  327. load_status: 1
  328. });
  329. app.globalData.showToast('服务器请求出错');
  330. }
  331. });
  332. },
  333. // 滚动加载
  334. scroll_lower(e) {
  335. this.get_data_list();
  336. },
  337. // 支付
  338. pay_event(e) {
  339. this.setData({
  340. is_show_payment_popup: true,
  341. temp_pay_value: e.currentTarget.dataset.value,
  342. order_select_ids: []
  343. });
  344. },
  345. // 支付弹窗关闭
  346. payment_popup_event_close(e) {
  347. this.setData({
  348. is_show_payment_popup: false
  349. });
  350. },
  351. // 支付弹窗发起支付
  352. popup_payment_event(e) {
  353. var payment_id = e.currentTarget.dataset.value || 0;
  354. var payment_type = e.currentTarget.dataset.type || '';
  355. this.setData({
  356. payment_id: payment_id,
  357. payment_type: payment_type
  358. });
  359. this.payment_popup_event_close();
  360. this.pay_handle(this.temp_pay_value);
  361. },
  362. // 支付方法
  363. pay_handle(order_ids) {
  364. // #ifdef H5
  365. // 微信环境判断是否已有web_openid、不存在则不继续执行跳转到插件进行授权
  366. if(!app.globalData.is_user_weixin_web_openid(order_ids, this.payment_id)) {
  367. return false;
  368. }
  369. // #endif
  370. // 支付方式
  371. var payment = null;
  372. for(var i in this.payment_list) {
  373. if(this.payment_list[i]['id'] == this.payment_id) {
  374. payment = this.payment_list[i];
  375. }
  376. }
  377. // 请求数据
  378. var post_data = {
  379. ids: order_ids,
  380. payment_id: this.payment_id
  381. };
  382. // h5自定义重定向地址
  383. // #ifdef H5
  384. if(payment != null) {
  385. post_data['redirect_url'] = encodeURIComponent(base64.encode(app.globalData.get_page_url(false)+(this.nav_status_index > 0 ? '?status='+this.nav_status_index : '')));
  386. // paypal支付方式使用respond_url返回地址、移除重定向地址
  387. if(payment.payment == 'PayPal') {
  388. post_data['respond_url'] = post_data['redirect_url'];
  389. delete post_data['redirect_url'];
  390. }
  391. }
  392. // #endif
  393. // 请求支付接口
  394. uni.showLoading({
  395. title: "请求中..."
  396. });
  397. uni.request({
  398. url: app.globalData.get_request_url("pay", "order"),
  399. method: 'POST',
  400. data: post_data,
  401. dataType: 'json',
  402. success: res => {
  403. uni.hideLoading();
  404. if (res.data.code == 0) {
  405. // 是否直接支付成功
  406. if ((res.data.data.is_success || 0) == 1) {
  407. this.order_item_pay_success_handle(order_ids);
  408. app.globalData.showToast('支付成功', 'success');
  409. } else {
  410. // 支付方式类型
  411. switch (res.data.data.is_payment_type) {
  412. // 正常线上支付
  413. case 0:
  414. var data = res.data.data;
  415. // #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU || MP-TOUTIAO
  416. this.common_pay_handle(this, data, order_ids);
  417. // #endif
  418. // #ifdef MP-KUAISHOU
  419. this.kuaishou_pay_handle(this, data, order_ids);
  420. // #endif
  421. // #ifdef MP-QQ
  422. this.qq_pay_handle(this, data, order_ids);
  423. // #endif
  424. // #ifdef H5
  425. this.h5_pay_handle(this, data, order_ids);
  426. // #endif
  427. break;
  428. // 线下支付
  429. case 1:
  430. var order_ids_arr = order_ids.split(',');
  431. var temp_data_list = this.data_list;
  432. for (var i in temp_data_list) {
  433. if (order_ids_arr.indexOf(temp_data_list[i]['id']) != -1) {
  434. temp_data_list[i]['is_under_line'] = 1;
  435. }
  436. }
  437. this.setData({
  438. data_list: temp_data_list
  439. });
  440. app.globalData.alert({
  441. msg: res.data.msg,
  442. is_show_cancel: 0
  443. });
  444. break;
  445. // 钱包支付
  446. case 2:
  447. this.order_item_pay_success_handle(order_ids);
  448. app.globalData.showToast('支付成功', 'success');
  449. break;
  450. // 默认
  451. default:
  452. app.globalData.showToast('支付类型有误');
  453. }
  454. }
  455. } else {
  456. // 是否返回html代码展示、则提示错误
  457. if(res.data.code == -6666 && (res.data.data || null) != null) {
  458. this.setData({
  459. popup_view_pay_data: res.data.data,
  460. popup_view_pay_html_is_show: true
  461. });
  462. } else {
  463. app.globalData.showToast(res.data.msg);
  464. }
  465. }
  466. },
  467. fail: () => {
  468. uni.hideLoading();
  469. app.globalData.showToast('服务器请求出错');
  470. }
  471. });
  472. },
  473. // 快手小程序
  474. kuaishou_pay_handle(self, data, order_ids) {
  475. uni.pay({
  476. orderInfo: data.data,
  477. serviceId: '1',
  478. success: res => {
  479. // 数据设置
  480. self.order_item_pay_success_handle(order_ids);
  481. // 跳转支付页面
  482. uni.navigateTo({
  483. url: "/pages/paytips/paytips?code=9000"
  484. });
  485. },
  486. fail: res => {
  487. app.globalData.showToast('支付失败');
  488. }
  489. });
  490. },
  491. // 微信、支付宝、百度、头条、QQ
  492. common_pay_handle(self, data, order_ids) {
  493. uni.requestPayment({
  494. // #ifdef MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || MP-KUAISHOU
  495. orderInfo: data.data,
  496. // #endif
  497. // #ifdef MP-QQ
  498. package: data.data,
  499. // #endif
  500. // #ifdef MP-WEIXIN
  501. timeStamp: data.data.timeStamp,
  502. nonceStr: data.data.nonceStr,
  503. package: data.data.package,
  504. signType: data.data.signType,
  505. paySign: data.data.paySign,
  506. // #endif
  507. // #ifdef MP-TOUTIAO
  508. service: 5,
  509. // #endif
  510. success: res => {
  511. // #ifdef MP-ALIPAY
  512. if (res.resultCode != 9000) {
  513. app.globalData.showToast(res.memo || '支付失败');
  514. return false;
  515. }
  516. // #endif
  517. // #ifdef MP-TOUTIAO
  518. if (res.code != 0) {
  519. app.globalData.showToast('支付失败');
  520. return false;
  521. }
  522. // #endif
  523. // 数据设置
  524. self.order_item_pay_success_handle(order_ids);
  525. // 跳转支付页面
  526. uni.navigateTo({
  527. url: "/pages/paytips/paytips?code=9000"
  528. });
  529. },
  530. fail: res => {
  531. app.globalData.showToast('支付失败');
  532. }
  533. });
  534. },
  535. // QQ支付处理
  536. qq_pay_handle(self, data, order_ids) {
  537. // 是否微信支付
  538. if(data.payment.payment == 'Weixin') {
  539. uni.requestWxPayment({
  540. url: data.data,
  541. referer: app.globalData.data.request_url,
  542. success: function(res) {
  543. app.globalData.alert({msg: '支付成功后、请不要重复支付、如果订单状态未成功请联系客服处理', is_show_cancel: 0});
  544. self.get_data_list();
  545. },
  546. fail: function (res) {
  547. app.globalData.showToast('支付失败');
  548. }
  549. });
  550. } else {
  551. self.common_pay_handle(self, data, order_ids);
  552. }
  553. },
  554. // h5支付处理
  555. h5_pay_handle(self, data, order_ids) {
  556. // 字符串则为跳转地址直接进入
  557. if(typeof data.data == 'string') {
  558. window.location.href = data.data;
  559. } else {
  560. var status = false;
  561. // 微信jsapi
  562. if(data.payment.payment == 'Weixin' && (data.data.appId || null) != null && (data.data.timeStamp || null) != null && (data.data.nonceStr || null) != null && (data.data.package || null) != null && (data.data.signType || null) != null && (data.data.paySign || null) != null) {
  563. status = true;
  564. function onBridgeReady() {
  565. WeixinJSBridge.invoke("getBrandWCPayRequest", {
  566. appId: data.data.appId,
  567. timeStamp: data.data.timeStamp,
  568. nonceStr: data.data.nonceStr,
  569. package: data.data.package,
  570. signType: data.data.signType,
  571. paySign: data.data.paySign
  572. },
  573. function(res) {
  574. if(res.err_msg == "get_brand_wcpay_request:ok") {
  575. // 数据设置
  576. self.order_item_pay_success_handle(order_ids);
  577. // 跳转支付页面
  578. uni.navigateTo({
  579. url: "/pages/paytips/paytips?code=9000"
  580. });
  581. }
  582. });
  583. }
  584. if(typeof WeixinJSBridge == "undefined") {
  585. if(document.addEventListener) {
  586. document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
  587. } else if (document.attachEvent) {
  588. document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
  589. document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
  590. }
  591. } else {
  592. onBridgeReady();
  593. }
  594. }
  595. // 二维码展示
  596. if((data.data.qrcode_url || null) != null && (data.data.name || null) != null && (data.data.check_url || null) != null && (data.data.order_no || null) != null) {
  597. status = true;
  598. // 显示支付窗口
  599. this.setData({
  600. popup_view_pay_data: data.data,
  601. popup_view_pay_qrcode_is_show: true
  602. });
  603. // 定时校验支付状态
  604. var timer = setInterval(function() {
  605. uni.request({
  606. url: app.globalData.get_request_url("paycheck", "order"),
  607. method: 'POST',
  608. data: {
  609. order_no: self.popup_view_pay_data.order_no,
  610. },
  611. dataType: 'json',
  612. success: res => {
  613. uni.hideLoading();
  614. if (res.data.code == 0) {
  615. // 清除定时和支付数据
  616. clearInterval(self.popup_view_pay_timer);
  617. self.setData({
  618. popup_view_pay_data: null,
  619. popup_view_pay_qrcode_is_show: false
  620. });
  621. // 数据设置
  622. self.order_item_pay_success_handle(order_ids);
  623. // 跳转支付页面
  624. uni.navigateTo({
  625. url: "/pages/paytips/paytips?code=9000"
  626. });
  627. } else {
  628. // -300支付中、其它状态则提示错误
  629. if(res.data.code != -300) {
  630. clearInterval(self.popup_view_pay_timer);
  631. app.globalData.showToast(res.data.msg);
  632. }
  633. }
  634. },
  635. fail: () => {
  636. clearInterval(self.popup_view_pay_timer);
  637. app.globalData.showToast('服务器请求出错');
  638. }
  639. });
  640. }, 3000);
  641. self.setData({
  642. popup_view_pay_timer: timer
  643. });
  644. }
  645. // 返回html表单
  646. if((data.data.html || null) != null) {
  647. status = true;
  648. var div = document.createElement('paydivform');
  649. div.innerHTML= data.data.html;
  650. document.body.appendChild(div);
  651. var fm = document.forms;
  652. if(fm.length > 0) {
  653. fm[0].submit();
  654. }
  655. }
  656. // 未匹配到的支付处理方式
  657. if(!status) {
  658. app.globalData.showToast(data.payment.name+'支付方式还未适配');
  659. }
  660. }
  661. },
  662. // 支付成功数据设置
  663. order_item_pay_success_handle(order_ids) {
  664. var order_ids_arr = order_ids.split(',');
  665. var temp_data_list = this.data_list;
  666. // 数据设置
  667. for (var i in temp_data_list) {
  668. if (order_ids_arr.indexOf(temp_data_list[i]['id']) != -1) {
  669. temp_data_list[i]['operate_data']['is_pay'] = 0;
  670. temp_data_list[i]['operate_data']['is_cancel'] = 0;
  671. switch (parseInt(temp_data_list[i]['order_model'])) {
  672. // 销售模式
  673. case 0:
  674. temp_data_list[i]['status'] = 2;
  675. temp_data_list[i]['status_name'] = '待发货';
  676. break;
  677. // 自提模式
  678. case 2:
  679. temp_data_list[i]['status'] = 2;
  680. temp_data_list[i]['status_name'] = '待取货';
  681. break;
  682. // 虚拟模式
  683. case 3:
  684. temp_data_list[i]['status'] = 3;
  685. temp_data_list[i]['status_name'] = '待收货';
  686. break;
  687. }
  688. }
  689. }
  690. this.setData({
  691. data_list: temp_data_list
  692. });
  693. },
  694. // 取消
  695. cancel_event(e) {
  696. uni.showModal({
  697. title: '温馨提示',
  698. content: '取消后不可恢复,确定继续吗?',
  699. confirmText: '确认',
  700. cancelText: '不了',
  701. success: result => {
  702. if (result.confirm) {
  703. // 参数
  704. var id = e.currentTarget.dataset.value;
  705. var index = e.currentTarget.dataset.index;
  706. // 加载loding
  707. uni.showLoading({
  708. title: '处理中...'
  709. });
  710. uni.request({
  711. url: app.globalData.get_request_url("cancel", "order"),
  712. method: 'POST',
  713. data: {
  714. id: id
  715. },
  716. dataType: 'json',
  717. success: res => {
  718. uni.hideLoading();
  719. if (res.data.code == 0) {
  720. var temp_data_list = this.data_list;
  721. temp_data_list[index]['status'] = 5;
  722. temp_data_list[index]['status_name'] = '已取消';
  723. temp_data_list[index]['operate_data']['is_cancel'] = 0;
  724. temp_data_list[index]['operate_data']['is_pay'] = 0;
  725. temp_data_list[index]['operate_data']['is_delete'] = 1;
  726. temp_data_list[index]['is_can_launch_aftersale'] = 0;
  727. this.setData({
  728. data_list: temp_data_list
  729. });
  730. app.globalData.showToast(res.data.msg, 'success');
  731. } else {
  732. app.globalData.showToast(res.data.msg);
  733. }
  734. },
  735. fail: () => {
  736. uni.hideLoading();
  737. app.globalData.showToast('服务器请求出错');
  738. }
  739. });
  740. }
  741. }
  742. });
  743. },
  744. // 收货
  745. collect_event(e) {
  746. uni.showModal({
  747. title: '温馨提示',
  748. content: '请确认已收到货物或已完成,操作后不可恢复,确定继续吗?',
  749. confirmText: '确认',
  750. cancelText: '不了',
  751. success: result => {
  752. if (result.confirm) {
  753. // 参数
  754. var id = e.currentTarget.dataset.value;
  755. var index = e.currentTarget.dataset.index;
  756. // 加载loding
  757. uni.showLoading({
  758. title: '处理中...'
  759. });
  760. uni.request({
  761. url: app.globalData.get_request_url("collect", "order"),
  762. method: 'POST',
  763. data: {
  764. id: id
  765. },
  766. dataType: 'json',
  767. success: res => {
  768. uni.hideLoading();
  769. if (res.data.code == 0) {
  770. var temp_data_list = this.data_list;
  771. temp_data_list[index]['status'] = 4;
  772. temp_data_list[index]['status_name'] = '已完成';
  773. temp_data_list[index]['operate_data']['is_collect'] = 0;
  774. temp_data_list[index]['operate_data']['is_comments'] = 1;
  775. temp_data_list[index]['operate_data']['is_delete'] = 1;
  776. this.setData({
  777. data_list: temp_data_list
  778. });
  779. app.globalData.showToast(res.data.msg, 'success');
  780. } else {
  781. app.globalData.showToast(res.data.msg);
  782. }
  783. },
  784. fail: () => {
  785. uni.hideLoading();
  786. app.globalData.showToast('服务器请求出错');
  787. }
  788. });
  789. }
  790. }
  791. });
  792. },
  793. // 删除
  794. delete_event(e) {
  795. uni.showModal({
  796. title: '温馨提示',
  797. content: '删除后不可恢复,确定继续吗?',
  798. confirmText: '确认',
  799. cancelText: '不了',
  800. success: result => {
  801. if (result.confirm) {
  802. // 参数
  803. var id = e.currentTarget.dataset.value;
  804. var index = e.currentTarget.dataset.index;
  805. // 加载loding
  806. uni.showLoading({
  807. title: '处理中...'
  808. });
  809. uni.request({
  810. url: app.globalData.get_request_url("delete", "order"),
  811. method: 'POST',
  812. data: {
  813. id: id
  814. },
  815. dataType: 'json',
  816. success: res => {
  817. uni.hideLoading();
  818. if (res.data.code == 0) {
  819. var temp_data_list = this.data_list;
  820. temp_data_list.splice(index, 1);
  821. var len = temp_data_list.length;
  822. this.setData({
  823. data_list: temp_data_list,
  824. data_list_loding_status: (len == 0) ? 0 : 3,
  825. data_bottom_line_status: (len == 0) ? false : this.data_bottom_line_status,
  826. });
  827. app.globalData.showToast(res.data.msg, 'success');
  828. } else {
  829. app.globalData.showToast(res.data.msg);
  830. }
  831. },
  832. fail: () => {
  833. uni.hideLoading();
  834. app.globalData.showToast('服务器请求出错');
  835. }
  836. });
  837. }
  838. }
  839. });
  840. },
  841. // 催催
  842. rush_event(e) {
  843. app.globalData.showToast("催促成功", 'success');
  844. },
  845. // 导航事件
  846. nav_event(e) {
  847. this.setData({
  848. nav_status_index: e.currentTarget.dataset.index || 0,
  849. data_page: 1,
  850. order_select_ids: []
  851. });
  852. // 重新拉取数据
  853. this.get_data_list(1);
  854. },
  855. // 售后订单事件
  856. orderaftersale_event(e) {
  857. var oid = e.currentTarget.dataset.oid || 0;
  858. var did = e.currentTarget.dataset.did || 0;
  859. if (oid == 0 || did == 0) {
  860. app.globalData.showToast("参数有误");
  861. return false;
  862. }
  863. // 进入售后页面
  864. uni.navigateTo({
  865. url: "/pages/user-orderaftersale-detail/user-orderaftersale-detail?oid=" + oid + "&did=" + did
  866. });
  867. },
  868. // 订单评论
  869. comments_event(e) {
  870. uni.navigateTo({
  871. url: "/pages/user-order-comments/user-order-comments?id=" + e.currentTarget.dataset.value
  872. });
  873. },
  874. // 选中处理
  875. selected_event(e) {
  876. var oid = e.currentTarget.dataset.oid || 0;
  877. var temp_select_ids = this.order_select_ids;
  878. if (temp_select_ids.indexOf(oid) == -1) {
  879. temp_select_ids.push(oid);
  880. } else {
  881. for (var i in temp_select_ids) {
  882. if (temp_select_ids[i] == oid) {
  883. temp_select_ids.splice(i, 1);
  884. }
  885. }
  886. }
  887. this.setData({
  888. order_select_ids: temp_select_ids
  889. });
  890. },
  891. // 合并支付
  892. pay_merge_event(e) {
  893. this.setData({
  894. is_show_payment_popup: true,
  895. temp_pay_value: this.order_select_ids.join(',')
  896. });
  897. },
  898. // url事件
  899. url_event(e) {
  900. app.globalData.url_event(e);
  901. },
  902. // 支付二维码展示窗口事件
  903. popup_view_pay_qrcode_event_close(e) {
  904. this.setData({
  905. popup_view_pay_qrcode_is_show: false
  906. });
  907. clearInterval(this.popup_view_pay_timer);
  908. },
  909. // 支付html展示窗口事件
  910. popup_view_pay_html_event_close(e) {
  911. this.setData({
  912. popup_view_pay_html_is_show: false
  913. });
  914. },
  915. // 页面卸载
  916. onUnload(e) {
  917. clearInterval(this.popup_view_pay_timer);
  918. }
  919. }
  920. };
  921. </script>
  922. <style>
  923. @import './user-order.css';
  924. </style>