|
- var app = getApp();
- const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
- const extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {}
- const Http = require("../../utils/HttpBasics");
- const config = require("../../config/config.js");
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- navigationBarHeight,
- num:1,
- showShade:false,
- coverImg:"",
- title:"",
- salePriceStr:"",//单价
- freightPriceStr:"",//运费
- remainInventory: "",//库存
- seti:[],
- area:"",
- address:"",
- consignee:"",
- mobile:"",
- },
- goAddStie(){
- wx.navigateTo({
- url: '/pages/siteAdd/siteAdd?url=/pages/fillIndent/fillIndent',
- })
- },
- setSite(e){
- let id = e.currentTarget.dataset.id
- let arr = []
- arr = this.data.seti.filter(item=>{
- return item.id == id
- })[0]
- console.log(arr)
- this.setData({
- area: arr.regionStr,
- address: arr.address,
- consignee: arr.consignee,
- mobile: arr.mobile,
- })
- },
- getSetiLsit(){
- Http.get({
- url: config.api.siteList,
- data:{
- pageNum: 1,
- pageSize: 1000
- }
- }).then(res=>{
- let temp = res.data.list
- if(temp.length>0){
-
- temp.map(item => {
- // let regionStr = ""
- let tempstr = ""
- JSON.parse(item.region).map(item2 => {
- tempstr += item2
- })
- item.regionStr = tempstr
- })
-
- console.log(temp, "temp")
- this.setData({
- seti: temp,
- })
- let tempRegion = JSON.parse(temp[0].region)
- let str = ""
- tempRegion.map(item => { str += item })
- this.setData({
- area: str,
- address: temp[0].address,
- consignee: temp[0].consignee,
- mobile: temp[0].mobile
- })
- }
-
-
-
- }).catch(err => {
- wx.showToast({
- title: err.message ? err.message : err.data,
- icon: 'none',
- duration: 2000,
-
- });
- })
- },
- addNum(){
- let num = this.data.num
- if (this.data.num >= this.data.remainInventory){
- wx.showToast({
- title: '购买总数超库存',
- icon: 'none',
- duration: 2000,
- })
- }else{
- num = num + 1
- this.setData({
- num: num
- })
- }
-
- },
- dleNum(){
- let num = this.data.num
- if (this.data.num <=1){
-
- wx.showToast({
- title: '购买总数不能为0',
- icon: 'none',
- duration: 2000,
- })
- }else{
-
- num = num - 1
- this.setData({
- num: num
- })
- }
- },
- hieShade(){
- this.setData({
- showShade:false
- })
- },
- showTShade(){
- this.setData({
- showShade: true
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- id:options.id
- })
- this.getCouponDetail()
- this.getSetiLsit()
- },
- getCouponDetail(){
- Http.get({
- url: config.api.couponDetail,
- data:{
- couponChannelId:this.data.id
- }
- }).then(res=>{
- let temp = res.data
- this.setData({
- coverImg: temp.coverImg,
- title: temp.title,
- salePriceStr: temp.salePriceStr,
- freightPriceStr: temp.freightPriceStr,
- remainInventory: temp.remainInventory
- })
- }).catch(err=>{
- wx.showToast({
- title: err.message ? err.message : err.data,
- icon: 'none',
- duration: 2000,
-
- });
- })
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- }
- })
|