小程序--确认订单

懒得写页面 专栏收录该内容
19 篇文章 0 订阅

<import src="../../template/baseNavigationBar.wxml"/>
<template is="navigationBar" data="{{...item}}"></template>
<view class="order_address" bindtap="bindaddress">
    <view class="select_address"><text class="iconfont icon-map_line-"></text>点击去选择地址</view>
    <view><text class="iconfont icon-arrowright"></text></view>
</view>
<view class="Receiving_address" bindtap="bindaddress">
    <view>
        <view class="name_iphone">天津 天津市 津南区</view>
        <view class="address">天安门后广场</view>
        <view class="name_iphone">张三 1313212313</view>
    </view>
    <view><text class="iconfont icon-arrowright"></text></view>
</view>

<view class="goods_msg">
    <view class="goods_img"><image src="../../images/img.png" mode="widthFix"></image></view>
    <view class="goods_content">共1件 <text class="iconfont icon-arrowright"></text></view>
</view>

<view class="msg_list">
    <view class="msg_item">
        <view>商品原价</view>
        <view>¥11.8</view>
    </view>
    <view class="msg_item">
        <view>配送费</view>
        <view>包邮</view>
    </view>
    <view class="msg_item">
        <view>商品优惠</view>
        <view>-¥11.8</view>
    </view>
    <view class="Total">
       合计 <text class="Total_price">¥9.8</text>
    </view>
</view>

<view class="order_pay">
    <view class="pay_money">付款 <text class="Total_price">¥9.8</text></view>
    <view class="submit_order" bindtap="bindSubmitOrder">提交订单</view>
</view>
@import "../../lib/style/iconfont.wxss";
@import "../../lib/style/base.wxss";
@import "../../lib/style/baseNavigationBar.wxss";
page {
    background-color: #f3f3f3;
}
.order_address {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 160rpx 20rpx 20rpx;
    height: 200rpx;
    line-height: 200rpx;
    background: white;
    border-radius: 10rpx;
    padding: 30rpx;
}
.Receiving_address {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20rpx;
    height: 200rpx;
    background: white;
    border-radius: 10rpx;
    padding: 30rpx;
}
.name_iphone {
    color: #7e7e7e;
    font-size: 24rpx;
}
.address {
    font-size: 32rpx;
    padding: 20rpx 0;
}
.select_address {
    color: #7e7e7e;
}
.icon-arrowright {
    font-size: 28rpx;
}
.icon-map_line- {
    margin-right: 10rpx;
}
.goods_msg {
    display: flex;
    margin: 20rpx;
    background: white;
    border-radius: 10rpx;
    padding: 30rpx;
    align-items: center;
}
.goods_img {
    width: 100rpx;
    height: 100rpx;
    overflow: hidden;
    margin-right: 20rpx;
    flex-shrink: 0;
}
.goods_img image {
    width: 100%;
    border-radius: 50%;
}
.goods_content {
    flex: 1;
    text-align: right;
    font-size: 24rpx;
}
.msg_list {
    margin: 20rpx;
    background: white;
    border-radius: 10rpx;
}
.msg_item {
    display: flex;
    justify-content: space-between;
    margin: 0 20rpx;
    padding: 30rpx 0;
    border-bottom: 2rpx solid #f3f3f3;
}
.Total {
    text-align: right;
    margin: 0 20rpx;
    padding: 30rpx 0;
    font-size: 32rpx;
}
.Total_price {
    color: #ad0e12;
    font-size: 32rpx;
}
.order_pay {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 93rpx;
    line-height: 93rpx;
    justify-content: space-between;
    background: white;

}
.submit_order {
    width: 32%;
    background: #ad0e12;
    color: white;
    font-size: 32rpx;
    text-align: center;
}
.pay_money {
    font-size: 32rpx;
    margin-left: 30rpx;
}
// pages/confirm_order/confirm_order.js
const app = getApp();
var MBC = require("../../../../core/core.js");
var api = require("../../../../config/api.config.js");
Page({

  /**
   * 页面的初始数据
   */
  data: {
    address_info: {}, //地址信息
    goods_info: [], //商品信息
    goods_count: '', //商品件数
    goods_freight: '', //运费
    goods_price: '', //商品价格
    total_price: '', //合计价格
    item: {
      iconfontBack: "icon-arrowleft",
      navigationBarTitle: "确认订单",
      statusBarHeight: app.globalData.statusBarHeight
    },
    statusBarHeight: app.globalData.statusBarHeight,
    goods_id: '', //商品id
    goods_num: '', //商品数量
    type: '', //选项
    order_message: '', //订单留言
    cart_ids: [], // 购物车商品id
  },
  //选择地址
  bindaddress: function() {

    var type = this.data.type;

    if (type == 1) {
      var goods_id = this.data.goods_id;
      var goods_num = this.data.goods_num;
      wx.navigateTo({
        url: '../myAddress/myAddress' + '?goods_id=' + goods_id + '&goods_num=' + goods_num + '&type=' + type
      })
    } else {
      var cart_ids = JSON.stringify(this.data.cart_ids);
      wx.navigateTo({
        url: '../myAddress/myAddress?cart_ids=' + cart_ids + '&type=' + type
      })
    }


  },
  // 留言
  bindwaitMsg: function(event) {
    console.log(event.detail.value);
    this.setData({
      order_message: event.detail.value, // 订单留言
    })
  },


  /**
   * 支付订单
   */
  payOrder: function(orderHash, order_id) {
    var that = this;
    var order_hash = orderHash;
    console.log(order_hash)
    //呼起微信支付
    MBC.Ajax({
      url: api.getPayConfig,
      is_login: true,
      data: {
        hash: order_hash,
        platform: 'miniProgram',
        channel: 'weixin'
      },
      success: function(res) {
        wx.requestPayment({
          'timeStamp': res.result.parameters.timeStamp,
          'nonceStr': res.result.parameters.nonceStr,
          'package': res.result.parameters.package,
          'signType': 'MD5',
          'paySign': res.result.parameters.paySign,
          'success': function(res) {
            console.log(res);
            MBC.Ajax({
              url: api.payOrder,
              is_login: true,
              data: {
                hash: order_hash
              },
              success: function(res) {
                console.log(res)
                var status = res.result.status;
                if (status == 2) {
                  wx.showToast({
                    title: '支付成功',
                  });
                  wx.redirectTo({
                    url: '../orderInfo/orderInfo?order_id=' + order_id,
                  })

                } else {
                  wx.showToast({
                    title: '支付失败,请稍后刷新',
                  })
                }

              }
            })
          },
          'fail': function(res) {
            console.log(res);
            wx.redirectTo({
              url: '../orderInfo/orderInfo?order_id=' + order_id,
            })
          }
        })
      }
    })

  },
  //  提交订单
  bindSubmitOrder: function(e) {
    var form_id = e.detail.formId;
    var that = this;
    var type = this.data.type;
    if (type == 1) {
      MBC.Ajax({
        url: api.submit,
        is_login: true,
        data: {
          form_id: form_id,
          order_message: this.data.order_message, //地址信息
          address_id: this.data.address_info.address_id, //地址id
          receiver_name: this.data.address_info.receiver_name, //收件人姓名
          receiver_phone: this.data.address_info.receiver_phone, //收件手机号
          receiver_city: this.data.address_info.city, //收件城市
          receiver_address_details: this.data.address_info.detail_address, //收件详细地址
          type: this.data.type, //选项
          goods_id: this.data.goods_id, //商品id
          goods_num: this.data.goods_num, //商品数量
        },
        success: function(res) {
          that.payOrder(res.result.hash, res.result.order_id);
        },
        fail: function(res) {

        }
      })
    } else if (type == 2) {
      MBC.Ajax({
        url: api.submit,
        is_login: true,
        data: {
          form_id: form_id,
          order_message: this.data.order_message, //地址信息
          address_id: this.data.address_info.address_id, //地址id
          receiver_name: this.data.address_info.receiver_name, //收件人姓名
          receiver_phone: this.data.address_info.receiver_phone, //收件手机号
          receiver_city: this.data.address_info.city, //收件城市
          receiver_address_details: this.data.address_info.detail_address, //收件详细地址
          type: this.data.type, //选项
          cart_ids: this.data.cart_ids, //购物车id
        },
        success: function(res) {
          that.payOrder(res.result.hash, res.result.order_id);
        },
        fail: function(res) {

        }
      })
    }

  },
  //返回上一页
  onBack: function() {
    wx.navigateBack({
      delta: 1
    })

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    var type = options.type;
 
 
    if (type == 1) {
      that.setData({
        goods_id: options.goods_id,
        goods_num: options.goods_num,
        type: options.type,
      })
      // 立即购买
      //直接购买
      MBC.Ajax({
        url: api.confirm,
        is_login: true,
        data: {
          goods_id: that.data.goods_id,
          goods_num: that.data.goods_num,
          type: type
        },
        success: function (res) {
          console.log(res);
          that.setData({
            address_info: res.result.address_info, //地址信息
            goods_info: res.result.goods_info, //商品信息
            goods_count: res.result.goods_count, //商品件数
            goods_freight: res.result.goods_freight, //运费
            goods_price: res.result.goods_price, //商品价格
            total_price: res.result.total_price, //合计价格
          })

        },
        fail: function (res) {
          console.log(res);
          //获取信息失败
        }
      })
      
    } else {
      that.setData({
        type: options.type,
        cart_ids: JSON.parse(options.cart_ids),
      })
      //   购物车
      MBC.Ajax({
        url: api.confirm,
        is_login: true,
        data: {
          cart_ids: that.data.cart_ids,
          type: type
        },
        success: function (res) {
          console.log(res);
          that.setData({
            address_info: res.result.address_info, //地址信息
            goods_info: res.result.goods_info, //商品信息
            goods_count: res.result.goods_count, //商品件数
            goods_freight: res.result.goods_freight, //运费
            goods_price: res.result.goods_price, //商品价格
            total_price: res.result.total_price, //合计价格
          })

        },
        fail: function (res) {
          console.log(res);
          //获取信息失败
        }
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function(options) {
    var that = this;
    var goods_id = that.data.goods_id;
    var goods_num = that.data.goods_num;
    var type = that.data.type;
    var cart_ids = that.data.cart_ids;
    console.log(that.data.address_id);
    // if (type == 1) {
      
    // } else if (type == 2) {
      
    // }
    if (that.data.address_id){
      // 获取指定地址信息
      MBC.Ajax({
        url: api.getOne,
        is_login: true,
        data: {
          address_id: that.data.address_id
        },
        success: function (res) {
          that.setData({
            address_info: res.result.address_info
          })
        },
        fail: function (res) {

        }
      })
    }
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})

 

  • 3
    点赞
  • 6
    评论
  • 11
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

打赏
文章很值,打赏犒劳作者一下
相关推荐
vs 2017 git成功 miyao 亲测可行 1.注册 ssh key 本地方生成 复制到远端 2. 远端建立仓库 3.在 网站上点击sourcetree 会自动打开本地sourcetree 。 本地先安装 好sourcetree ,并注册一下 4.sourcetree拉取远端文件 5.在vs中打开 自动可以操作了 在线购物商城微信小程序前端和后台源码 源码描述: 一、源码特点 在线购物商城微信小程序前端和后台数据管理系统源码,使用.net开发,测试无Bug,感兴趣的欢迎下载 二、微信小程序功能 1、 会员自动授权登录注册 2、 产品分类、产品检索、产品筛选、产品详情、 3、 广告展示、 4、 购物车 6、 收货地址 7、 订单提交微信支付 8、 订单检索等功能 三、后台功能 1、 后台会员系统:会员列表、会员基本信息,积分明细、余额明细、购物记录、收货地址(在系统设置的频道管理可以开启此功能) 2、 后台系统设置:导航栏目、分类管理、 OAuth设置 、支付设置、扩展字段 、频道管理、模型管理、站点基本信息等功能设置 3、 订单管理:在线购物订单查看、发货、确认 4、 产品管理:分类管理 、产品管理 、 积分产品管理 四、注意事项 1、开发环境为Visual Studio 2010,数据库为SQLServer2008,使用.net 4.0开发。 2、管理员登陆名:admin 密码:admin888 3、默认数据库连接字符串在webconfig配置文件中修改 4、DB文件夹中是数据库脚本文件,使用sqlerver工具运行即可 5、cmsWeb文件夹里面是api接口后台 xcx文件夹是微信小程序 DataBase文件夹是数据库文件
©️2020 CSDN 皮肤主题: 1024 设计师:白松林 返回首页

打赏

Acitylion

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值