123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- let app = getApp();
- let host = app.globalData.servsers; // 请求的url
- Page({
- data: {
- host: host,
- isSelect: "", //默认全部
- dataStateArray: [{
- state: '0',
- label: "全部",
- },
- {
- state: '1',
- label: "待付款",
- },
- {
- state: '2',
- label: "待审核",
- },
- {
- state: '3',
- label: "待发货",
- },
- {
- state: '4',
- label: "待收货",
- },
- {
- state: '5',
- label: "已完成",
- }
- ],
- goodsList: [],
- page: 1, //默认第一页
- limit:10,//默认就展示10条数据
- requestStatic:true, //默认可以下拉请求
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let that = this;
- if ('state' in options) {
- that.setData({
- isSelect: options.state
- })
- }
- that.getOrderList(that, that.data.isSelect)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- console.log("到底了")
- let that = this;
- if(that.data.requestStatic){
- that.setData({
- page:that.data.page +1
- })
- that.getOrderList(that)
- }
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- tab(e) { // tab切换
- this.setData({
- isSelect: e.currentTarget.dataset.state,
- page:1,
- goodsList:[],
- requestStatic:true
- })
- this.getOrderList(this)
- },
- getOrderList(that) {
- let data = {
- user_id: app.globalData.user_id,
- status: that.data.isSelect,
- offset: that.data.page,
- limit: that.data.limit
- }
- if (wx.getStorageSync('channelIdObj').channelAccountId){
- data.channel_account_id = wx.getStorageSync('channelIdObj').channelAccountId;
- }
- wx.request({
- url: host + '/orderapi/orderlist',
- method: 'get',
- data:data,
- success(res) {
- console.log(res, "orderItem")
- let data = res.data,goodsList = that.data.goodsList;
- data.forEach(res=>{
- let total = 0;
- res.list_order_aff_data.forEach(el=>{
- total += el.com_price * 1
- })
- res.com_price_total = total;
- })
- goodsList.push(...data)
- that.setData({
- goodsList: goodsList,
- requestStatic:res.data.length == that.data.limit
- })
- }
- })
- },
- orderInfor: function (e) { //之前查看详情
- // wx.navigateTo({
- // url: '/pages/confirmedList/confirmedList?goosdListnew=' + newCarts
- // })
- },
- uploadImg(e){
- // 上传支付凭证
- let orderId = e.currentTarget.dataset.orderid, that = this, index = e.currentTarget.dataset.index;
- wx.chooseImage({
- success(res) {
- const tempFilePaths = res.tempFilePaths
- wx.uploadFile({
- url: host + '/payOrderFile', // 仅为示例,非真实的接口地址
- filePath: tempFilePaths[0],
- header: {
- "Content-Type": "multipart/form-data"
- },
- name: 'file',
- formData: {
- file: tempFilePaths[0],
- orderId: orderId,
- },
- success(res) {
- console.log(res, '我上传完了')
- if(res.data){
- wx.showToast({
- title: '支付凭证上传成功!',
- icon:'none'
- })
- let goodsList = that.data.goodsList;
- goodsList[index].list_order_aff_data[0].pay_order = res.data
- that.setData({
- goodsList: goodsList
- })
- } else {
- wx.showToast({
- title: res.data,
- icon: 'error'
- })
- }
- }
- })
- }
- })
-
- },
- seePayOrder(e){
- let that = this, imgSrc =[];
- if (e.currentTarget.dataset.src[0].pay_order){
- imgSrc.push(host+e.currentTarget.dataset.src[0].pay_order)
- }
- if (e.currentTarget.dataset.src[0].final_payment) {
- imgSrc.push(host +e.currentTarget.dataset.src[0].final_payment)
- }
- console.log(imgSrc)
- wx.previewImage({
- current: imgSrc[0],
- urls: imgSrc
- })
- }
- })
|