From ab319c746f7424f00bf2ace342bda89b01453d57 Mon Sep 17 00:00:00 2001 From: shaojing <2901156235@qq.com> Date: Fri, 26 Jul 2024 16:28:10 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/info/museumInfo/index.js | 20 +- pages/info/sceneProductInfo/index.js | 1659 +++++++++++---------- pages/info/sceneProductInfo/index.json | 4 +- pages/info/sceneProductInfo/index.wxml | 37 +- pages/info/sceneProductInfo/index.wxss | 108 +- pages/order/components/contact/index.wxml | 5 +- pages/order/components/contact/index.wxss | 4 +- pages/order/components/date/index.js | 57 +- pages/order/components/date/index.wxml | 45 +- pages/order/components/date/index.wxss | 54 +- pages/order/scene/index.js | 51 +- pages/order/scene/index.json | 6 +- pages/order/scene/index.wxml | 66 +- pages/order/scene/index.wxss | 133 +- 14 files changed, 1362 insertions(+), 887 deletions(-) diff --git a/pages/info/museumInfo/index.js b/pages/info/museumInfo/index.js index a4f8e8a..a4c3859 100644 --- a/pages/info/museumInfo/index.js +++ b/pages/info/museumInfo/index.js @@ -28,7 +28,9 @@ Page({ shareImg: null, showShareFlag: false, showQrCode:false, - wxqrcode:null + wxqrcode:null, + date: "", + time: "", }, /** @@ -77,6 +79,20 @@ Page({ }) this.getAct() }, + // 获取日期 + changeDate: function (e) { + this.setData({ + date: e.detail + }) + console.log(this.data.date); + }, + // 获取分时 + changeTime: function (e) { + this.setData({ + time: e.detail + }) + console.log(this.data.time); + }, getAct: function () { if (this.data.actList.length >= this.data.actTotal || this.data.isGroup == 1) return; commonApi._post('scene/get_scene_act_list', { @@ -464,6 +480,8 @@ Page({ isGroup: this.data.isGroup, isTeam: this.data.info.team_order && this.data.isGroup?1:0 } + app.globalData.product.date = this.data.date + app.globalData.product.time = this.data.time app.globalData.index = 0 wx.navigateTo({ url: '/pages/order/scene/index?type=museum' diff --git a/pages/info/sceneProductInfo/index.js b/pages/info/sceneProductInfo/index.js index 2abd7b0..e9d5b05 100644 --- a/pages/info/sceneProductInfo/index.js +++ b/pages/info/sceneProductInfo/index.js @@ -6,867 +6,916 @@ import util from "../../../utils/util" import QRCode from '../../../utils/weapp-qrcode.js' let app = getApp() Page({ - /** - * 页面的初始数据 - */ - data: { - info: null, - bookingInfo: null, - bookingInfoTitle: "", - safeBottom: app.globalData.safeBottom, - isLike: 0, - comment: [], - commentTotal: 0, - isTest: true, - retailId: "", - shareImg: null, - showShareFlag: false, - showAllowance: false, - allowance_data: null, - //购物车数量 - productNum: 1, - skuIndex: 0, - aniSkuIndex: -1, - cartCount: 0, - cartImgInfo: null, - cartTop: 0, - top: 0, - skuList: [], //立即预定的列表 - sku_ids: [], - showQrCode: false, - wxqrcode: null + /** + * 页面的初始数据 + */ + data: { + info: null, + bookingInfo: null, + bookingInfoTitle: "", + safeBottom: app.globalData.safeBottom, + isLike: 0, + comment: [], + commentTotal: 0, + isTest: true, + retailId: "", + shareImg: null, + showShareFlag: false, + showAllowance: false, + allowance_data: null, + //购物车数量 + productNum: 1, + skuIndex: 0, + aniSkuIndex: -1, + cartCount: 0, + cartImgInfo: null, + cartTop: 0, + top: 0, + skuList: [], //立即预定的列表 + sku_ids: [], + showQrCode: false, + wxqrcode: null, + product: {}, + date: "", + time: "", + showDate:false, + showPrice:0 + }, - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - console.log(options); - if (!options.id) { - util.back() - return; - } - if (options.retailId) { - this.setData({ - retailId: options.retailId - }) - } - this.setData({ - id: options.id + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + console.log(options); + if (!options.id) { + util.back() + return; + } + if (options.retailId) { + this.setData({ + retailId: options.retailId + }) + } + this.setData({ + id: options.id + }) + commonApi._post("scene/detail", { + id: options.id + }).then(res => { + let flag = false + if (!res.data) { + wx.showToast({ + title: '产品已下架', + icon: 'none' }) - commonApi._post("scene/detail", { - id: options.id - }).then(res => { - let flag = false - if (!res.data) { - wx.showToast({ - title: '产品已下架', - icon: 'none' - }) - setTimeout(() => { - util.back(); - }, 1000) - return; - } - res.data.display_tags = (res.data.display_tags ? res.data.display_tags.split(",") : []).splice(0, 2); - // 如果是带有指定good_id的 那么取指定的 - if (options.gid) { - let pItem = res.data.product.find(item => item.id == options.gid); - if (pItem) { - res.data.product = [pItem]; - } + setTimeout(() => { + util.back(); + }, 1000) + return; + } + res.data.display_tags = (res.data.display_tags ? res.data.display_tags.split(",") : []).splice(0, 2); + // 如果是带有指定good_id的 那么取指定的 + if (options.gid) { + let pItem = res.data.product.find(item => item.id == options.gid); + if (pItem) { + res.data.product = [pItem]; + } + } + // 如果带有指定skuid的话 那么取指定的sku展示 + if (options.skuid) { + let pItem = null; + for (let i = 0; i < res.data.product.length; i++) { //3 + for (let j = 0; j < res.data.product[i].sku.length; j++) { //4 + if (res.data.product[i].sku[j].id == options.skuid) { + res.data.product[i].sku = [res.data.product[i].sku[j]]; + pItem = res.data.product[i]; + break; } - // 如果带有指定skuid的话 那么取指定的sku展示 - if (options.skuid) { - let pItem = null; - for (let i = 0; i < res.data.product.length; i++) { //3 - for (let j = 0; j < res.data.product[i].sku.length; j++) { //4 - if (res.data.product[i].sku[j].id == options.skuid) { - res.data.product[i].sku = [res.data.product[i].sku[j]]; - pItem = res.data.product[i]; - break; - } - } - } - if (pItem) { - res.data.product = [pItem]; + } + } + if (pItem) { + res.data.product = [pItem]; + } + } else if (options.zhuanti_type) { + flag = true + commonApi._post("theme/getYihuFreeList", { + zhuanti_type: options.zhuanti_type + }).then(res1 => { + let skuArr = res1.data.sku_ids + let newArr = [] + for (let i = 0; i < res.data.product.length; i++) { //3 + for (let j = 0; j < res.data.product[i].sku.length; j++) { //4 + for (let k = 0; k < skuArr.length; k++) { + if (res.data.product[i].sku[j].id == skuArr[k]) { + newArr.push(res.data.product[i].sku[j]) } - } else if (options.zhuanti_type) { - flag = true - commonApi._post("theme/getYihuFreeList", { - zhuanti_type: options.zhuanti_type - }).then(res1 => { - let skuArr = res1.data.sku_ids - let newArr = [] - for (let i = 0; i < res.data.product.length; i++) { //3 - for (let j = 0; j < res.data.product[i].sku.length; j++) { //4 - for (let k = 0; k < skuArr.length; k++) { - if (res.data.product[i].sku[j].id == skuArr[k]) { - newArr.push(res.data.product[i].sku[j]) - } - } - } - res.data.product[i].sku = newArr; - } - res.data.product.map(product => { - product.sku.map(sku => { - sku.display_tags = (sku.display_tags ? sku.display_tags.split(",") : []).splice(0, 2); - }) - }) - this.setData({ - info: res.data - }) - var arr = [] - res.data.product.forEach((item, index) => { - item.sku.forEach(itemB => { - itemB.proIndex = index - arr.push(itemB) - }) - }); - this.setData({ - skuList: arr - }) - util.pagePoint({ - event: 'scene_view', - param: { - type: res.data.type, - id: res.data.id - } - }, 1) - this.BroswerRecord() - }) - + } } - console.log(res.data.product); - if (flag) { - return + res.data.product[i].sku = newArr; + } + res.data.product.map(product => { + product.sku.map(sku => { + sku.display_tags = (sku.display_tags ? sku.display_tags.split(",") : []).splice(0, 2); + }) + }) + this.setData({ + info: res.data + }) + var arr = [] + res.data.product.forEach((item, index) => { + item.sku.forEach(itemB => { + itemB.proIndex = index + arr.push(itemB) + }) + }); + this.setData({ + skuList: arr + }) + util.pagePoint({ + event: 'scene_view', + param: { + type: res.data.type, + id: res.data.id } + }, 1) + this.BroswerRecord() + }) + } + console.log(res.data.product); + if (flag) { + return + } - // res.data.listimg = res.data.listimg?res.data.listimg.split(","):[]; - res.data.product.map(product => { - product.sku.map(sku => { - sku.display_tags = (sku.display_tags ? sku.display_tags.split(",") : []).splice(0, 2); - }) - }) - this.setData({ - info: res.data - }) - var arr = [] - res.data.product.forEach((item, index) => { - item.sku.forEach(itemB => { - itemB.proIndex = index - arr.push(itemB) - }) - }); - this.setData({ - skuList: arr - }) - util.pagePoint({ - event: 'scene_view', - param: { - type: res.data.type, - id: res.data.id - } - }, 1) - this.BroswerRecord() + + // res.data.listimg = res.data.listimg?res.data.listimg.split(","):[]; + res.data.product.map(product => { + product.sku.map(sku => { + sku.display_tags = (sku.display_tags ? sku.display_tags.split(",") : []).splice(0, 2); }) - // 获取收藏的状态 - if (wx.getStorageSync("jstrip_token")) { - commonApi.user_post("scene/is_scene_collection", { - scene_id: options.id - }).then(res => { - this.setData({ - isLike: res.data - }) - }) + }) + this.setData({ + info: res.data + }) + var arr = [] + res.data.product.forEach((item, index) => { + item.sku.forEach(itemB => { + itemB.proIndex = index + arr.push(itemB) + }) + }); + this.setData({ + skuList: arr + }) + util.pagePoint({ + event: 'scene_view', + param: { + type: res.data.type, + id: res.data.id } - commonApi._post("ask/getQuestionList", { - scene_id: options.id, - page_no: 1, - page_num: 3 - }).then(res => { - this.setData({ - ask: res.data.rows - }) + }, 1) + this.BroswerRecord() + }) + // 获取收藏的状态 + if (wx.getStorageSync("jstrip_token")) { + commonApi.user_post("scene/is_scene_collection", { + scene_id: options.id + }).then(res => { + this.setData({ + isLike: res.data }) - // 获取评价列表 - commonApi._post("scene/get_comment", { - scene_id: options.id - }).then(res => { - res.data.list.map(item => { - item.rate = Number(item.rate) - }) - this.setData({ - comment: res.data.list.splice(0, 2), - commentTotal: res.data.total - }) - let arr = this.data.comment - arr.map((item) => { - if (item.img_list) { - let arr = item.img_list.split(',') - item.img_list = arr + }) + } + commonApi._post("ask/getQuestionList", { + scene_id: options.id, + page_no: 1, + page_num: 3 + }).then(res => { + this.setData({ + ask: res.data.rows + }) + }) + // 获取评价列表 + commonApi._post("scene/get_comment", { + scene_id: options.id + }).then(res => { + res.data.list.map(item => { + item.rate = Number(item.rate) + }) + this.setData({ + comment: res.data.list.splice(0, 2), + commentTotal: res.data.total + }) + let arr = this.data.comment + arr.map((item) => { + if (item.img_list) { + let arr = item.img_list.split(',') + item.img_list = arr - } else { - item.img_list = [] - } - }) - this.setData({ - comment: arr - }) + } else { + item.img_list = [] + } + }) + this.setData({ + comment: arr + }) + }) + }, + // 获取日期 + changeDate: function (e) { + this.setData({ + date: e.detail + }) + console.log(this.data.date); + }, + // 获取分时 + changeTime: function (e) { + console.log(e); + this.setData({ + time: e.detail + }) + console.log(this.data.time); + }, + changeAllowance: function () { + this.setData({ + showAllowance: !this.data.showAllowance + }) + }, + BroswerRecord: function () { + setTimeout(() => { + if (app.globalData.uuid) { + commonApi._post('browse/browse_record', { + type: "scene", + title: this.data.info.title, + drive: "mini", + source_id: this.data.info.id, + url: "/pages/info/sceneProductInfo/index?id=" + this.data.info.id, + uuid: app.globalData.uuid + }).then(res => {}) + } else { + this.BroswerRecord(); + } + }, 500) + }, + like: function () { + let id = this.data.id, + isLike = Number(this.data.isLike); + commonApi.user_post(isLike != 1 ? "scene/scene_collection" : "scene/scene_cancel_collection", { + scene_id: id + }).then(res => { + if (res.code == 1) { + wx.showToast({ + title: '操作成功', }) - }, - changeAllowance: function () { this.setData({ - showAllowance: !this.data.showAllowance + isLike: isLike == 1 ? 0 : 1 }) - }, - BroswerRecord: function () { - setTimeout(() => { - if (app.globalData.uuid) { - commonApi._post('browse/browse_record', { - type: "scene", - title: this.data.info.title, - drive: "mini", - source_id: this.data.info.id, - url: "/pages/info/sceneProductInfo/index?id=" + this.data.info.id, - uuid: app.globalData.uuid - }).then(res => {}) - } else { - this.BroswerRecord(); + } + }) + }, + gotolocation: function () { + let info = this.data.info; + wx.openLocation({ + latitude: Number(info.lat), + longitude: Number(info.lon) + }) + }, + audioGuide: function () { + wx.navigateToMiniProgram({ + appId: 'wx74f380bc721a0379', + path: '/pages/listen/listen?title=君到苏州' + }) + }, + showBookingInfo: function (e) { + this.setData({ + bookingInfo: e.currentTarget.dataset.item.sku_model, + bookingInfoTitle: e.currentTarget.dataset.item.sku_name + }) + util.pagePoint({ + event: "scene_notice", + param: { + type: this.data.info.type, + id: this.data.info.id + } + }, 1) + }, + closeMask: function () { + this.setData({ + bookingInfo: null + }) + }, + // order: function (e) { + // console.log(e) + // if (e.currentTarget.dataset.disable == 1) return; + // util.pagePoint({ + // event: 'scene_order', + // param: { + // type: this.data.info.type, + // id: this.data.info.id + // } + // }, 1) + // wx.setStorageSync('login_from', 'scene_order_login') + // wx.setStorageSync('order_from', 'scene_order_submit') + // app.globalData.couponInfo = null; + // app.globalData.retailId = this.data.retailId; + // // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product; + // app.globalData.product = e.currentTarget.dataset; + // wx.navigateTo({ + // url: '/pages/order/scene/index', + // }) + // }, + selectSku: function (e) { + console.log(e.currentTarget.dataset.item); + if (e.currentTarget.dataset.item.stock == 0 && e.currentTarget.dataset.item.is_third_stock != 1) { + wx.showToast({ + title: "该商品暂无库存", + icon: 'none' + }) + return + } + let index = e.currentTarget.dataset.index; + this.setData({ + skuIndex: index, + productNum: 1 + }) + + }, + order: function (e) { + commonApi.user_post("/product/checkStock", { + sku_id: this.data.skuList[this.data.skuIndex].id, + }).then(res => { + if (res && res.code != 1) { + wx.showModal({ + title: "温馨提示", + content: '商品已经被抢光啦~要不要瞧瞧别的~', + showCancel: false + }) + return; + } else { + app.globalData.postProduct = [] + app.globalData.list = [] + if (this.data.skuFlag == 'order') { + if (e.currentTarget.dataset.disable === 1) return; + util.pagePoint({ + event: 'scene_order', + param: { + type: this.data.info.type, + id: this.data.info.id } - }, 500) - }, - like: function () { - let id = this.data.id, - isLike = Number(this.data.isLike); - commonApi.user_post(isLike != 1 ? "scene/scene_collection" : "scene/scene_cancel_collection", { - scene_id: id - }).then(res => { + }, 1) + wx.setStorageSync('login_from', 'scene_order_login') + wx.setStorageSync('order_from', 'scene_order_submit') + app.globalData.couponInfo = null; + app.globalData.retailId = this.data.retailId; + // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product; + // let sku = {sku:e.currentTarget.dataset.product.sku[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product} + // let sku = { + // sku: this.data.skuList[this.data.skuIndex] + // }, + // product = { + // product: this.data.info.product[this.data.skuList[this.data.skuIndex].proIndex] + // } + // product.productNum = this.data.productNum + app.globalData.product.date = this.data.date + app.globalData.product.time = this.data.time + // app.globalData.product = { + // ...sku, + // ...product + // } + app.globalData.index = 0 + wx.navigateTo({ + url: '/pages/order/scene/index', + }) + } else { + commonApi.user_post("cart/add_sku", { + sku_id: this.data.skuList[this.data.skuIndex].id, + num: this.data.productNum + }).then(res => { if (res.code == 1) { - wx.showToast({ - title: '操作成功', + commonApi.user_post('cart/get_list', {}).then(res => { + this.setData({ + cartCount: res.data.length //5 }) + }) + // 加动效 + this.setData({ + skuFlag: null, + aniSkuIndex: this.data.skuIndex, + cartImgInfo: null + }) + setTimeout(() => { this.setData({ - isLike: isLike == 1 ? 0 : 1 + aniSkuIndex: -1 }) - } - }) - }, - gotolocation: function () { - let info = this.data.info; - wx.openLocation({ - latitude: Number(info.lat), - longitude: Number(info.lon) - }) - }, - audioGuide: function () { - wx.navigateToMiniProgram({ - appId: 'wx74f380bc721a0379', - path: '/pages/listen/listen?title=君到苏州' - }) - }, - showBookingInfo: function (e) { - this.setData({ - bookingInfo: e.currentTarget.dataset.item.sku_model, - bookingInfoTitle: e.currentTarget.dataset.item.sku_name - }) - util.pagePoint({ - event: "scene_notice", - param: { - type: this.data.info.type, - id: this.data.info.id - } - }, 1) - }, - closeMask: function () { - this.setData({ - bookingInfo: null - }) - }, - // order: function(e){ - // console.log(e) - // if (e.currentTarget.dataset.disable == 1) return; - // util.pagePoint({ - // event: 'scene_order', - // param: { - // type: this.data.info.type, - // id: this.data.info.id - // } - // }, 1) - // wx.setStorageSync('login_from', 'scene_order_login') - // wx.setStorageSync('order_from', 'scene_order_submit') - // app.globalData.couponInfo = null; - // app.globalData.retailId = this.data.retailId; - // // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product; - // app.globalData.product = e.currentTarget.dataset; - // wx.navigateTo({ - // url: '/pages/order/scene/index', - // }) - // }, - selectSku: function (e) { - console.log(e.currentTarget.dataset.item); - if (e.currentTarget.dataset.item.stock == 0 && e.currentTarget.dataset.item.is_third_stock != 1) { - wx.showToast({ - title: "该商品暂无库存", - icon: 'none' - }) - return - } - let index = e.currentTarget.dataset.index; - this.setData({ - skuIndex: index, - productNum:1 - }) - - }, - order: function (e) { - commonApi.user_post("/product/checkStock", { - sku_id: this.data.skuList[this.data.skuIndex].id, - }).then(res => { - if (res && res.code != 1) { wx.showModal({ - title: "温馨提示", - content: '商品已经被抢光啦~要不要瞧瞧别的~', - showCancel: false - }) - return; - } else { - app.globalData.postProduct = [] - app.globalData.list = [] - if (this.data.skuFlag == 'order') { - if (e.currentTarget.dataset.disable === 1) return; - util.pagePoint({ - event: 'scene_order', - param: { - type: this.data.info.type, - id: this.data.info.id - } - }, 1) - wx.setStorageSync('login_from', 'scene_order_login') - wx.setStorageSync('order_from', 'scene_order_submit') - app.globalData.couponInfo = null; - app.globalData.retailId = this.data.retailId; - // let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product; - // let sku = {sku:e.currentTarget.dataset.product.sku[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product} - let sku = { - sku: this.data.skuList[this.data.skuIndex] - }, - product = { - product: this.data.info.product[this.data.skuList[this.data.skuIndex].proIndex] - } - product.productNum = this.data.productNum - app.globalData.product = { - ...sku, - ...product + title: "提示", + content: "去购物车结算?", + success: function (res) { + if (res.confirm) { + wx.navigateTo({ + url: '/pages/user/cartlist/list', + }) } - app.globalData.index = 0 - wx.navigateTo({ - url: '/pages/order/scene/index', - }) - } else { - commonApi.user_post("cart/add_sku", { - sku_id: this.data.skuList[this.data.skuIndex].id, - num: this.data.productNum - }).then(res => { - if (res.code == 1) { - commonApi.user_post('cart/get_list', {}).then(res => { - this.setData({ - cartCount: res.data.length //5 - }) - }) - // 加动效 - this.setData({ - skuFlag: null, - aniSkuIndex: this.data.skuIndex, - cartImgInfo: null - }) - setTimeout(() => { - this.setData({ - aniSkuIndex: -1 - }) - wx.showModal({ - title: "提示", - content: "去购物车结算?", - success: function (res) { - if (res.confirm) { - wx.navigateTo({ - url: '/pages/user/cartlist/list', - }) - } - } - }) - }, 650) - } - }) - } - } - }) - }, - pagePoint: function (e) { - util.pagePoint({ - event: e.currentTarget.dataset.event, - param: { - type: this.data.info.type, - id: this.data.info.id + } + }) + }, 650) } - }, 1) - }, - // 分享 - share: function () { - if (!wx.getStorageSync("jstrip_token")) { - wx.setStorageSync('login_from', 'scene_share_login') - commonApi.user_post("user/getMyInfo", {}).then(res => {}).catch(err => {}) - return; + }) } - if (!this.data.shareImg) { + } + }) + }, + pagePoint: function (e) { + util.pagePoint({ + event: e.currentTarget.dataset.event, + param: { + type: this.data.info.type, + id: this.data.info.id + } + }, 1) + }, + // 分享 + share: function () { + if (!wx.getStorageSync("jstrip_token")) { + wx.setStorageSync('login_from', 'scene_share_login') + commonApi.user_post("user/getMyInfo", {}).then(res => {}).catch(err => {}) + return; + } + if (!this.data.shareImg) { + wx.showToast({ + title: '图片生成中,稍后再试', + icon: 'none' + }) + return; + } + this.setData({ + showShareFlag: !this.data.showShareFlag + }) + }, + // 保存 + save() { + let url = this.data.shareImg, + that = this; + wx.authorize({ + /* 这个就是保存相册的 */ + scope: 'scope.writePhotosAlbum', + success() { + wx.saveImageToPhotosAlbum({ + filePath: url, + success(res) { wx.showToast({ - title: '图片生成中,稍后再试', - icon: 'none' + title: '保存成功', + icon: "success" }) - return; - } - this.setData({ - showShareFlag: !this.data.showShareFlag + that.setData({ + showShareFlag: !that.data.showShareFlag + }) + util.pagePoint({ + event: 'scene_share_save', + param: { + type: that.data.info.type, + id: that.data.info.id + } + }, 1) + }, + fail(res) { + wx.showToast({ + title: '保存失败', + icon: 'none' + }) + } }) - }, - // 保存 - save() { - let url = this.data.shareImg, - that = this; - wx.authorize({ - /* 这个就是保存相册的 */ - scope: 'scope.writePhotosAlbum', - success() { - wx.saveImageToPhotosAlbum({ - filePath: url, - success(res) { - wx.showToast({ - title: '保存成功', - icon: "success" - }) - that.setData({ - showShareFlag: !that.data.showShareFlag - }) - util.pagePoint({ - event: 'scene_share_save', - param: { - type: that.data.info.type, - id: that.data.info.id - } - }, 1) - }, - fail(res) { - wx.showToast({ - title: '保存失败', - icon: 'none' - }) - } - }) - }, - complete(res) { - /* 这里判断一下如果没有授权重新打开设置选项 */ - wx.getSetting({ - success(res) { - if (!res.authSetting['scope.writePhotosAlbum']) { - /* 打开设置的方法 */ - // opensit(); - wx.showToast({ - title: '请打开权限后再试', - icon: 'none' - }) - } - } - }); + }, + complete(res) { + /* 这里判断一下如果没有授权重新打开设置选项 */ + wx.getSetting({ + success(res) { + if (!res.authSetting['scope.writePhotosAlbum']) { + /* 打开设置的方法 */ + // opensit(); + wx.showToast({ + title: '请打开权限后再试', + icon: 'none' + }) } + } }); + } + }); - }, - // 绘制海报 - drawImg: function () { - var that = this, - userinfo = wx.getStorageSync('jstrip_userInfo'); - if (!userinfo) { - // 去登录 - return false; + }, + // 绘制海报 + drawImg: function () { + var that = this, + userinfo = wx.getStorageSync('jstrip_userInfo'); + if (!userinfo) { + // 去登录 + return false; + } + const ctx = wx.createCanvasContext('imageCanvas'); + // const device = wx.getSystemInfoSync(); + // const ratio = device.screenWidth / 750; + // 先获取到图片信息 + let promise2 = new Promise(function (resolve, reject) { + wx.getImageInfo({ + src: that.data.info.headimg, + success: function (res) { + resolve(res); + }, + fail: function (res) { + reject(res); } - const ctx = wx.createCanvasContext('imageCanvas'); - // const device = wx.getSystemInfoSync(); - // const ratio = device.screenWidth / 750; - // 先获取到图片信息 - let promise2 = new Promise(function (resolve, reject) { - wx.getImageInfo({ - src: that.data.info.headimg, - success: function (res) { - resolve(res); - }, - fail: function (res) { - reject(res); - } - }) - }) - let promise3 = new Promise(function (resolve, reject) { - let userid = wx.getStorageSync('jstrip_userid') - new QRCode('myQrcode', { - text: 'https://m.cloud.sz-trip.com/ScenicDetail?id=' + that.data.info.id + '&sharedUserId=' + userid + '&channel=-1', - width: 500, - height: 500, - padding: 12, // 生成二维码四周自动留边宽度,不传入默认为0 - correctLevel: QRCode.CorrectLevel.H, // 二维码可辨识度 - callback: (res) => { - resolve(res); - } - }) - }) - //成功得到图片信息后,开始绘图 - Promise.all([promise2, promise3]).then(imgs => { - ctx.save(); - ctx.beginPath(); //开始绘制 - that.handleBorderRect(ctx, 0, 0, 551 * ratio, 407 * ratio, 25 * ratio, '#ccc') - ctx.clip(); //画好了圆 剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内 这也是我们要save上下文的原因 - ctx.drawImage(imgs[0].path, 0, 0, 551 * ratio, 407 * ratio); - ctx.restore(); - ctx.save(); - that.handleBorderRect2(ctx, 0, 407 * ratio, 551 * ratio, 236 * ratio, 25 * ratio, '#fff') - ctx.restore(); - // 绘制二维码 - ctx.drawImage(imgs[1].path, 373 * ratio, 495 * ratio, 137 * ratio, 137 * ratio); - // 开始文字绘制 - ctx.setFillStyle("#000"); - ctx.setFontSize(30 * ratio); //字大小 - ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 - that.drawText(ctx, that.data.info.title, 25 * ratio, 450 * ratio, 480 * ratio, ratio); - // 售价 - ctx.setFillStyle("#D62828"); - ctx.setFontSize(40 * ratio); //字大小 - ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 - let price = "¥" + (that.data.info.price / 100); - let width = ctx.measureText(price).width; - ctx.fillText(price, 25 * ratio, 620 * ratio); - // 副标题 - ctx.setFillStyle("#999999"); - ctx.setFontSize(28 * ratio); //字大小 - ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 - let subtitle = that.data.info.sub_title - if (subtitle && subtitle.length > 10) { - subtitle = subtitle.substr(0, 10) + '...' - } - if (subtitle) { - ctx.fillText(subtitle, 25 * ratio, 540 * ratio); - } + }) + }) + let promise3 = new Promise(function (resolve, reject) { + let userid = wx.getStorageSync('jstrip_userid') + new QRCode('myQrcode', { + text: 'https://m.cloud.sz-trip.com/ScenicDetail?id=' + that.data.info.id + '&sharedUserId=' + userid + '&channel=-1', + width: 500, + height: 500, + padding: 12, // 生成二维码四周自动留边宽度,不传入默认为0 + correctLevel: QRCode.CorrectLevel.H, // 二维码可辨识度 + callback: (res) => { + resolve(res); + } + }) + }) + //成功得到图片信息后,开始绘图 + Promise.all([promise2, promise3]).then(imgs => { + ctx.save(); + ctx.beginPath(); //开始绘制 + that.handleBorderRect(ctx, 0, 0, 551 * ratio, 407 * ratio, 25 * ratio, '#ccc') + ctx.clip(); //画好了圆 剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内 这也是我们要save上下文的原因 + ctx.drawImage(imgs[0].path, 0, 0, 551 * ratio, 407 * ratio); + ctx.restore(); + ctx.save(); + that.handleBorderRect2(ctx, 0, 407 * ratio, 551 * ratio, 236 * ratio, 25 * ratio, '#fff') + ctx.restore(); + // 绘制二维码 + ctx.drawImage(imgs[1].path, 373 * ratio, 495 * ratio, 137 * ratio, 137 * ratio); + // 开始文字绘制 + ctx.setFillStyle("#000"); + ctx.setFontSize(30 * ratio); //字大小 + ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 + that.drawText(ctx, that.data.info.title, 25 * ratio, 450 * ratio, 480 * ratio, ratio); + // 售价 + ctx.setFillStyle("#D62828"); + ctx.setFontSize(40 * ratio); //字大小 + ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 + let price = "¥" + (that.data.info.price / 100); + let width = ctx.measureText(price).width; + ctx.fillText(price, 25 * ratio, 620 * ratio); + // 副标题 + ctx.setFillStyle("#999999"); + ctx.setFontSize(28 * ratio); //字大小 + ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 + let subtitle = that.data.info.sub_title + if (subtitle && subtitle.length > 10) { + subtitle = subtitle.substr(0, 10) + '...' + } + if (subtitle) { + ctx.fillText(subtitle, 25 * ratio, 540 * ratio); + } - // ctx.draw(); - // 划线价 - // ctx.setFillStyle("#999999"); - // ctx.setFontSize(32 * ratio); //字大小 - // ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 - // let market_price = "¥"+(Number(that.data.info.market_price)/100) - // ctx.fillText(market_price, 40*ratio + width, 620*ratio); - // let market_price_width = ctx.measureText(market_price).width; - // 划线 - // ctx.beginPath() - // ctx.setLineWidth(1) - // ctx.moveTo(40*ratio + width, 608*ratio) - // ctx.lineTo(45*ratio + width, 608*ratio) - // ctx.stroke(); - // 长按识别二维码 - // ctx.setFillStyle("#666"); - // ctx.setFontSize(22 * ratio); //字大小 - // ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 - // ctx.fillText("长按识别二维码", 404*ratio, 710*ratio); - // 长按图片转发或保存 - // ctx.setFillStyle("#000"); - // ctx.setFontSize(24 * ratio); //字大小 - // ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 - // ctx.fillText("长按图片保存到本地",(592*ratio - ctx.measureText("长按图片保存到本地").width)/2, 740*ratio); - ctx.draw(); - // 转为图片 - setTimeout(() => { - wx.canvasToTempFilePath({ - x: 0, - y: 0, - canvasId: 'imageCanvas', - success: function (res) { - that.setData({ - shareImg: res.tempFilePath - }) - }, - fail(err) { - console.log('agdgjgdajhg', err) - } - }) - }, 500) - return false; - }).catch(err => { - console.log("this err", err) + // ctx.draw(); + // 划线价 + // ctx.setFillStyle("#999999"); + // ctx.setFontSize(32 * ratio); //字大小 + // ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 + // let market_price = "¥"+(Number(that.data.info.market_price)/100) + // ctx.fillText(market_price, 40*ratio + width, 620*ratio); + // let market_price_width = ctx.measureText(market_price).width; + // 划线 + // ctx.beginPath() + // ctx.setLineWidth(1) + // ctx.moveTo(40*ratio + width, 608*ratio) + // ctx.lineTo(45*ratio + width, 608*ratio) + // ctx.stroke(); + // 长按识别二维码 + // ctx.setFillStyle("#666"); + // ctx.setFontSize(22 * ratio); //字大小 + // ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 + // ctx.fillText("长按识别二维码", 404*ratio, 710*ratio); + // 长按图片转发或保存 + // ctx.setFillStyle("#000"); + // ctx.setFontSize(24 * ratio); //字大小 + // ctx.setTextAlign('left'); //是否居中显示,参考点画布中线 + // ctx.fillText("长按图片保存到本地",(592*ratio - ctx.measureText("长按图片保存到本地").width)/2, 740*ratio); + ctx.draw(); + // 转为图片 + setTimeout(() => { + wx.canvasToTempFilePath({ + x: 0, + y: 0, + canvasId: 'imageCanvas', + success: function (res) { + that.setData({ + shareImg: res.tempFilePath + }) + }, + fail(err) { + console.log('agdgjgdajhg', err) + } }) - }, - // 圆角矩形 - handleBorderRect(ctx, x, y, w, h, r, color) { - ctx.beginPath(); - ctx.moveTo(x + w, y + h); - ctx.lineTo(x, y + h) - // 左上角 - ctx.arc(x + r, y + r, r, Math.PI, 1.5 * Math.PI); - ctx.moveTo(x + r, y); - ctx.lineTo(x + w - r, y); - ctx.lineTo(x + w, y + r); - // 右上角 - ctx.arc(x + w - r, y + r, r, 1.5 * Math.PI, 2 * Math.PI); - ctx.lineTo(x + w, y + h); - ctx.lineTo(x + w - r, y + h); - ctx.fillStyle = color; - ctx.fill(); - ctx.closePath(); - }, - handleBorderRect2(ctx, x, y, w, h, r, color) { - ctx.beginPath(); - ctx.moveTo(x, y); - ctx.lineTo(x + w, y) - // 右下角 - ctx.arc(x + w - r, y + h - r, r, 0, 0.5 * Math.PI); - ctx.lineTo(x + r, y + h); - ctx.lineTo(x, y + h - r); - // 左下角 - ctx.arc(x + r, y + h - r, r, 0.5 * Math.PI, Math.PI); - ctx.lineTo(x, y); - ctx.lineTo(x, y); - ctx.fillStyle = color; - ctx.fill(); - ctx.closePath(); - }, - // 绘制两行文字 - drawText: function (ctx, str, x, y, canvasWidth, ratio) { - let row = [], - temp = "", - chr = str.split(""); - for (var a = 0; a < chr.length; a++) { - if (ctx.measureText(temp).width < canvasWidth) { - temp += chr[a]; - } else { - a--; //这里添加了a-- 是为了防止字符丢失,效果图中有对比 - row.push(temp); - temp = ""; - } - } + }, 500) + return false; + }).catch(err => { + console.log("this err", err) + }) + }, + // 圆角矩形 + handleBorderRect(ctx, x, y, w, h, r, color) { + ctx.beginPath(); + ctx.moveTo(x + w, y + h); + ctx.lineTo(x, y + h) + // 左上角 + ctx.arc(x + r, y + r, r, Math.PI, 1.5 * Math.PI); + ctx.moveTo(x + r, y); + ctx.lineTo(x + w - r, y); + ctx.lineTo(x + w, y + r); + // 右上角 + ctx.arc(x + w - r, y + r, r, 1.5 * Math.PI, 2 * Math.PI); + ctx.lineTo(x + w, y + h); + ctx.lineTo(x + w - r, y + h); + ctx.fillStyle = color; + ctx.fill(); + ctx.closePath(); + }, + handleBorderRect2(ctx, x, y, w, h, r, color) { + ctx.beginPath(); + ctx.moveTo(x, y); + ctx.lineTo(x + w, y) + // 右下角 + ctx.arc(x + w - r, y + h - r, r, 0, 0.5 * Math.PI); + ctx.lineTo(x + r, y + h); + ctx.lineTo(x, y + h - r); + // 左下角 + ctx.arc(x + r, y + h - r, r, 0.5 * Math.PI, Math.PI); + ctx.lineTo(x, y); + ctx.lineTo(x, y); + ctx.fillStyle = color; + ctx.fill(); + ctx.closePath(); + }, + // 绘制两行文字 + drawText: function (ctx, str, x, y, canvasWidth, ratio) { + let row = [], + temp = "", + chr = str.split(""); + for (var a = 0; a < chr.length; a++) { + if (ctx.measureText(temp).width < canvasWidth) { + temp += chr[a]; + } else { + a--; //这里添加了a-- 是为了防止字符丢失,效果图中有对比 row.push(temp); + temp = ""; + } + } + row.push(temp); - //如果数组长度大于2 则截取前两个 - if (row.length > 2) { - var rowCut = row.slice(0, 2); - var rowPart = rowCut[1]; - var test = ""; - var empty = []; - for (var a = 0; a < rowPart.length; a++) { - if (ctx.measureText(test).width < canvasWidth - 30 * ratio) { - test += rowPart[a]; - } else { - break; - } - } - empty.push(test); - var group = empty[0] + "..." //这里只显示两行,超出的用...表示 - rowCut.splice(1, 1, group); - row = rowCut; - } - for (var b = 0; b < row.length; b++) { - ctx.fillText(row[b], x, y + b * 40 * ratio, canvasWidth); + //如果数组长度大于2 则截取前两个 + if (row.length > 2) { + var rowCut = row.slice(0, 2); + var rowPart = rowCut[1]; + var test = ""; + var empty = []; + for (var a = 0; a < rowPart.length; a++) { + if (ctx.measureText(test).width < canvasWidth - 30 * ratio) { + test += rowPart[a]; + } else { + break; } - }, - //加入购物车 - showCart: function () { - commonApi.user_post('wx/get_user_keep', { - jumpurl: '/pages/info/sceneProductInfo/index?id=' + this.data.id, - title: this.data.info.title, - type: 'mini' - }).then(res => { - if (res.data.subscribe == 0) { - this.setData({ - wxqrcode: res.data.qrcode, - showQrCode: true - }) - } else { - if (this.data.info.product[0].sku.length == 0) { - wx.showToast({ - title: '该产品未设置规格,不能加购', - icon: 'none' - }) - return; - } - this.setData({ - skuFlag: "cart" - }) - let that = this - wx.createSelectorQuery().select('#skuImg').boundingClientRect(function (res) { - that.setData({ - cartImgInfo: 'top:' + res.top + 'px;left:' + res.left + 'px;' - }) - }).exec() - } + } + empty.push(test); + var group = empty[0] + "..." //这里只显示两行,超出的用...表示 + rowCut.splice(1, 1, group); + row = rowCut; + } + for (var b = 0; b < row.length; b++) { + ctx.fillText(row[b], x, y + b * 40 * ratio, canvasWidth); + } + }, + //加入购物车 + showCart: function () { + commonApi.user_post('wx/get_user_keep', { + jumpurl: '/pages/info/sceneProductInfo/index?id=' + this.data.id, + title: this.data.info.title, + type: 'mini' + }).then(res => { + if (res.data.subscribe == 0) { + this.setData({ + wxqrcode: res.data.qrcode, + showQrCode: true }) - }, - hideSku: function () { + } else { + if (this.data.info.product[0].sku.length == 0) { + wx.showToast({ + title: '该产品未设置规格,不能加购', + icon: 'none' + }) + return; + } this.setData({ - skuFlag: null, - cartImgInfo: null + skuFlag: "cart" }) - }, - //加减数量 - minus: function () { - if (this.data.productNum == 1) return; + let that = this + wx.createSelectorQuery().select('#skuImg').boundingClientRect(function (res) { + that.setData({ + cartImgInfo: 'top:' + res.top + 'px;left:' + res.left + 'px;' + }) + }).exec() + } + }) + }, + hideSku: function () { + this.setData({ + skuFlag: null, + cartImgInfo: null + }) + }, + hideDate: function () { + this.setData({ + showDate: false + }) + }, + //加减数量 + minus: function () { + if (this.data.productNum == 1) return; + this.setData({ + productNum: this.data.productNum - 1 + }) + }, + add: function () { + if (this.data.productNum == this.data.skuList[this.data.skuIndex].sku_model.traveller_limit_num) { + wx.showToast({ + title: '本产品单笔限购' + this.data.skuList[this.data.skuIndex].sku_model.traveller_limit_num, + icon: 'none' + }); + } else { + this.setData({ + productNum: this.data.productNum + 1 + }) + } + }, + // 选择日期 + selectDate(e) { + console.log(e.currentTarget.dataset); + let sku = { + sku: e.currentTarget.dataset.sku + }, + product = { + product: e.currentTarget.dataset.product + } + console.log(sku,product); + product.productNum = 1 + app.globalData.product = { + ...sku, + ...product + } + console.log(app.globalData.product); + this.setData({ + product: product, + showDate: true, + skuFlag: 'order', + showPrice:e.currentTarget.dataset.sku.price + }) + }, + //立即预定 + showOrder: function () { + console.log(this.data.id); + commonApi.user_post('wx/get_user_keep', { + jumpurl: '/pages/info/sceneProductInfo/index?id=' + this.data.id, + title: this.data.info.title, + type: 'mini' + }).then(res => { + if (res.data.subscribe == 0) { this.setData({ - productNum: this.data.productNum - 1 + wxqrcode: res.data.qrcode, + showQrCode: true }) - }, - add: function () { - if (this.data.productNum == this.data.skuList[this.data.skuIndex].sku_model.traveller_limit_num){ - wx.showToast({ - title: '本产品单笔限购'+this.data.skuList[this.data.skuIndex].sku_model.traveller_limit_num, - icon:'none' - }); - }else{ + } else { + if (this.data.info.product[0].sku.length == 0) { + wx.showToast({ + title: '该产品未设置规格,不能购买', + icon: 'none' + }) + return; + } + if (this.data.info.product[0].type == 'line') { + wx.navigateTo({ + url: '/pages/order/road/index?id=' + this.data.info.product[0].id + }) + return + } this.setData({ - productNum: this.data.productNum + 1 + skuFlag: 'order' }) } - }, - //立即预定 - showOrder: function () { - console.log(this.data.id); - commonApi.user_post('wx/get_user_keep', { - jumpurl: '/pages/info/sceneProductInfo/index?id=' + this.data.id, - title: this.data.info.title, - type: 'mini' - }).then(res => { - if (res.data.subscribe == 0) { - this.setData({ - wxqrcode: res.data.qrcode, - showQrCode: true - }) - } else { - if (this.data.info.product[0].sku.length == 0) { - wx.showToast({ - title: '该产品未设置规格,不能购买', - icon: 'none' - }) - return; - } - if (this.data.info.product[0].type == 'line') { - wx.navigateTo({ - url: '/pages/order/road/index?id=' + this.data.info.product[0].id - }) - return - } - this.setData({ - skuFlag: 'order' - }) - } - }) + }) - }, + }, - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - if (app.globalData.configJson) { - this.setData({ - isTest: app.globalData.configJson.isTest - }) - } else { - setTimeout(() => { - this.onReady() - }, 300) - } - }, + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + if (app.globalData.configJson) { + this.setData({ + isTest: app.globalData.configJson.isTest + }) + } else { + setTimeout(() => { + this.onReady() + }, 300) + } + }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - console.log(11111); - commonApi.user_post('cart/get_list', {}).then(res => { - this.setData({ - cartCount: res.data.length //1 - }) - }) - if (!wx.getStorageSync('jstrip_token')) { - return; - } - if (this.data.info && this.data.info.id) { - this.drawImg() - //// 获取补贴 - // if (this.data.product.length == 1) { - // commonApi.user_post("product/getProductAllowancePrice", { - // product_code: this.data.product[0].product.product_code - // }).then(resTwo => { - // if (resTwo && resTwo.code == 1) { - // this.setData({ - // allowance_data: resTwo.data - // }) - // let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price) - // let sInfo = this.data.product[0].sku - // if (spread_price > 0) { - // if (spread_price < this.data.allowance_data.discount_rate / 100 * sInfo.price) { - // this.setData({ - // allowance_price: spread_price - // }) - // } else { - // this.setData({ - // allowance_price: this.data.allowance_data.discount_rate / 100 * sInfo.price - // }) - // } - // this.changePrice() - // } else { - // this.setData({ - // allowance_price: 0 - // }) - // } - // } - // }) - // } - //// 获取补贴结束 + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + console.log(11111); + commonApi.user_post('cart/get_list', {}).then(res => { + this.setData({ + cartCount: res.data.length //1 + }) + }) + if (!wx.getStorageSync('jstrip_token')) { + return; + } + if (this.data.info && this.data.info.id) { + this.drawImg() + //// 获取补贴 + // if (this.data.product.length == 1) { + // commonApi.user_post("product/getProductAllowancePrice", { + // product_code: this.data.product[0].product.product_code + // }).then(resTwo => { + // if (resTwo && resTwo.code == 1) { + // this.setData({ + // allowance_data: resTwo.data + // }) + // let spread_price = Number(this.data.allowance_data.discount_limit_price - this.data.allowance_data.user_used_price) + // let sInfo = this.data.product[0].sku + // if (spread_price > 0) { + // if (spread_price < this.data.allowance_data.discount_rate / 100 * sInfo.price) { + // this.setData({ + // allowance_price: spread_price + // }) + // } else { + // this.setData({ + // allowance_price: this.data.allowance_data.discount_rate / 100 * sInfo.price + // }) + // } + // this.changePrice() + // } else { + // this.setData({ + // allowance_price: 0 + // }) + // } + // } + // }) + // } + //// 获取补贴结束 - } else { - console.log(2222); - setTimeout(() => { - // this.onShow() - }, 200) - } + } else { + console.log(2222); + setTimeout(() => { + // this.onShow() + }, 200) + } - }, + }, - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { - }, + }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () { - }, + }, - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { - }, + }, - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () { - }, + }, - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () {} + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () {} }) \ No newline at end of file diff --git a/pages/info/sceneProductInfo/index.json b/pages/info/sceneProductInfo/index.json index 58e1fcb..73f696a 100644 --- a/pages/info/sceneProductInfo/index.json +++ b/pages/info/sceneProductInfo/index.json @@ -2,8 +2,8 @@ "usingComponents": { "title":"/pages/component/TitleHeader", "notice":"/pages/component/notice/notice", - "code":"../../order/components/wxqrCode/index" - + "code":"/pages/order/components/wxqrCode/index", + "date":"/pages/order/components/date" } } \ No newline at end of file diff --git a/pages/info/sceneProductInfo/index.wxml b/pages/info/sceneProductInfo/index.wxml index 11a7cae..a0aafb6 100644 --- a/pages/info/sceneProductInfo/index.wxml +++ b/pages/info/sceneProductInfo/index.wxml @@ -2,12 +2,7 @@ - - @@ -20,7 +15,6 @@ {{item}} - 开园时间:{{info.open_time}} @@ -51,10 +45,11 @@ 预订须知>> - {{sku.price?sku.price/100:0}} - + 立即预订 --> + class="btn{{item.flag==0 || sku.flag=='off'?' disable':''}}">预订 @@ -70,7 +65,7 @@ 加入购物车 - 立即预订 + 该商品已下架 @@ -110,7 +105,25 @@ --> - + + + + + + + + + + 合计: {{showPrice/100}} + + + 下一步 + + + + + + @@ -137,6 +150,8 @@ {{skuFlag=='cart'?'确认':'立即购买'}} + 该商品已下架 diff --git a/pages/info/sceneProductInfo/index.wxss b/pages/info/sceneProductInfo/index.wxss index 6afe625..878fa34 100644 --- a/pages/info/sceneProductInfo/index.wxss +++ b/pages/info/sceneProductInfo/index.wxss @@ -89,13 +89,13 @@ page { .box { margin: 20rpx; - background: white; + /* background: white; */ border-radius: 13rpx; } .box-top { line-height: 95rpx; - border-bottom: 1rpx solid #d9d9d9; + /* border-bottom: 1rpx solid #d9d9d9; */ font-weight: 500; color: #000; font-size: 35rpx; @@ -103,22 +103,27 @@ page { } .product-item { - margin: 0 20rpx; - padding: 27rpx 0; - border-bottom: 1rpx solid #ccc; + /* margin: 0 20rpx; */ + padding: 33rpx 26rpx 30rpx; + /* border-bottom: 1rpx solid #ccc; */ + background-color: rgba(11,137,142, .06); + border-radius: 13rpx; + margin-bottom: 18rpx; } .skutitle { - font-size: 29rpx; - color: #333; + font-family: PingFang SC; font-weight: 500; + font-size: 31rpx; + color: #000000; } .product-box { display: flex; align-items: flex-end; justify-content: space-between; - margin-top: 20rpx; + margin-top: 13rpx; + /* margin-top: 20rpx; */ } .product-left { @@ -131,13 +136,17 @@ page { } .product-tag { - font-size: 20rpx; + /* font-size: 20rpx; color: #0B898E; border-radius: 16rpx; line-height: 30rpx; - border: 1rpx solid; - padding: 0 15rpx; + border: 1rpx solid; */ + /* padding: 0 15rpx; */ margin-right: 13rpx; + font-family: PingFang SC; + font-weight: 400; + font-size: 23rpx; + color: #666666; } .product-tags .product-tags:last-child { @@ -145,25 +154,33 @@ page { } .order-tip-text { - margin-top: 33rpx; + /* margin-top: 33rpx; font-size: 24rpx; - color: #666; + color: #666; */ + font-weight: 400; + font-size: 23rpx; + color: #0B898E; + margin-top: 18rpx; } .product-right { text-align: center; flex-shrink: 0; + display: flex; + align-items: center; } .product-right .price { + font-weight: 500; color: #D62828; font-size: 24rpx; - margin-bottom: 20rpx; + /* margin-bottom: 20rpx; */ + margin-right: 19rpx; } .product-right .price text:nth-child(2) { font-weight: 500; - font-size: 33rpx; + font-size: 36rpx; } .product-right .price text:nth-child(3) { @@ -172,13 +189,22 @@ page { } .product-right .btn { - background: #D62828; + /* background: #D62828; color: #fff; border-radius: 30px; line-height: 60rpx; font-size: 29rpx; font-weight: 500; - width: 176rpx; + width: 176rpx; */ + width: 93rpx; + height: 80rpx; + background: #0B898E; + border-radius: 13rpx; + font-weight: 500; + font-size: 31rpx; + color: #FFFFFF; + text-align: center; + line-height: 80rpx; } .product-right .btn.disable { @@ -581,7 +607,7 @@ page { .btns .btn:nth-child(1) { margin-right: 3rpx; - border-radius: 39rpx 0 0 39rpx; + border-radius: 39rpx; } .btns .btn:nth-child(2) { @@ -843,4 +869,50 @@ page { } .btn-r{ border-radius: 39rpx !important; +} +.totalPrice { + font-family: PingFang SC; + font-weight: 500; + font-size: 48rpx; + color: #D62828; +} +.totalPrice::before { + content: "¥"; + font-size: 24rpx; +} +.bottom-box { + height: 133rpx; + background: #FFFFFF; + box-shadow: 0rpx -3rpx 8rpx 0rpx rgba(71,71,71,0.1); + padding: 0 50rpx; + display: flex; + justify-content: space-between; + align-items: center; +} +.next { + width: 250rpx; + height: 80rpx; + background: #D62828; + border-radius: 40rpx; + font-family: PingFang; + font-weight: bold; + font-size: 32rpx; + color: #FFFFFF; + text-align: center; + line-height: 80rpx; +} +.mask-content1 { + position: absolute; + left: 0; + right: 0; + bottom: 0; + width: 100%; + background: white; + border-radius: 12rpx; + overflow-y: auto; +} +.icon-close { + position: absolute; + top: 30rpx; + right: 30rpx; } \ No newline at end of file diff --git a/pages/order/components/contact/index.wxml b/pages/order/components/contact/index.wxml index 54bbe86..5e9d430 100644 --- a/pages/order/components/contact/index.wxml +++ b/pages/order/components/contact/index.wxml @@ -56,6 +56,9 @@ + + 出行人{{index+1}} + {{item.name}} 手机号{{item.tel}} @@ -64,7 +67,7 @@ - + diff --git a/pages/order/components/contact/index.wxss b/pages/order/components/contact/index.wxss index 9687713..e57dbe5 100644 --- a/pages/order/components/contact/index.wxss +++ b/pages/order/components/contact/index.wxss @@ -14,7 +14,7 @@ padding: 42rpx 20rpx 18rpx; } .contact-item { - padding: 30rpx 0; + padding: 30rpx 20rpx; /* border-bottom: 1rpx solid #ccc; */ display: flex; align-items: center; @@ -33,7 +33,7 @@ text-align: left; color: #666666; font-size: 25rpx; - margin: 0 60rpx; + margin: 0 30rpx; } .contact-item .contact-name { font-size: 28rpx; diff --git a/pages/order/components/date/index.js b/pages/order/components/date/index.js index 8e25a91..ece97ba 100644 --- a/pages/order/components/date/index.js +++ b/pages/order/components/date/index.js @@ -40,12 +40,17 @@ Component({ today:util.formatDate(new Date()), tomorrow:util.formatMing(new Date()), afterTom:util.formatHou(new Date()), + skuName:'', + monthList:[] }, lifetimes: { attached: function () { + console.log(app.globalData.product); + let skuName = app.globalData.product.sku.sku_name this.setData({ kjIdCom: app.globalData.kjId, - gpIdCom: app.globalData.gp_id || app.globalData.team_id + gpIdCom: app.globalData.gp_id || app.globalData.team_id, + skuName }) // 在组件实例进入页面节点树时执行 let product = app.globalData.product, today = util.formatDate(new Date()), end_date = util.formatDate(new Date(new Date().getTime() + 60 * 24 * 60 * 60 * 1000)); @@ -107,11 +112,32 @@ Component({ this.setData({ datelist: res.data }) - + res.data.forEach(item=> { + item.short_date = item.date.split("-").splice(1, 2).join("-") + item.week = this.getDay(item.date) + }) + let seldDate = '' + if (app.globalData.product.changeFlag) { + res.data.forEach(item=> { + if (item.date == app.globalData.product.date.date) { + seldDate = item + } + }) + setTimeout(() => { + this.changeDate(seldDate) + }) + // this.setData({ + // activeDate:seldDate + // }) + // this.getTimeStock() + } this.setData({ - threeDays: res.data.slice(0, 3) + threeDays: res.data.slice(0, 3), + monthList: res.data.slice(0, 30), }) + console.log(this.data.monthList); let index = this.data.threeDays.findIndex(item => item.date == this.data.activeDate.date) + console.log(this.data.activeDate); this.setData({ moreFlag: index != -1 }) @@ -136,6 +162,11 @@ Component({ * 组件的方法列表 */ methods: { + getDay: function (date) { + let d = new Date(date.replace(/-/g, '/')).getDay(); + let days = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]; + return days[d]; + }, showMoreDate: function () { this.setData({ showMoreDateFlag: true @@ -147,7 +178,7 @@ Component({ }) }, changeDate: function (e) { - let date = e.currentTarget.dataset.date; + let date = e.currentTarget ? e.currentTarget.dataset.date : e if (date.stock <= 0) return; if (date.stock == null) return; if (date.price == null) return; @@ -179,7 +210,10 @@ Component({ this.getTimeStock() }, getTimeStock: function () { - if (this.data.activeDate.is_time_stock != true) return; + if (this.data.activeDate.is_time_stock != true) { + this.triggerEvent("onChangeTime", '') + return + }; commonApi.user_post("product/product_timestock_price", { date: this.data.activeDate.date, sku_id: this.data.activeDate.sku_id ? this.data.activeDate.sku_id : app.globalData.product.sku.id @@ -195,9 +229,18 @@ Component({ return; } for (let i = 0; i < res.data.length; i++) { + if (res.data[i].stock_number > 0) { - timeIndex = i; - break; + if (app.globalData.product.changeFlag) { + if (res.data[i].start_time == app.globalData.product.time.start_time) { + timeIndex = i; + break; + } + } else { + timeIndex = i; + break; + } + } } this.setData({ diff --git a/pages/order/components/date/index.wxml b/pages/order/components/date/index.wxml index 90bbd65..9e884f6 100644 --- a/pages/order/components/date/index.wxml +++ b/pages/order/components/date/index.wxml @@ -1,13 +1,12 @@ - + {{item.tipText?item.tipText:'售罄'}} @@ -21,6 +20,48 @@ {{item.start_time}}-{{item.end_time}} 有票 售罄 不可定({{'余票'+item.stock_number}}) + --> + + {{skuName}} + + + 使用日期 + + + + + + {{item.week}} + {{item.short_date}} + 不可定 + {{item.price==0 || kjIdCom?'免费':('¥'+item.price/100)}} + + {{item.tipText?item.tipText:'售罄'}} + + + + + + 更多日期 + + + > + + + + {{activeDate.short_date}} + {{activeDate.price==0 || kjIdCom?'免费':('¥'+activeDate.price/100)}} + + + + + + 选择时段 + + + {{item.start_time}}-{{item.end_time}} 有票 售罄 不可定({{'余票'+item.stock_number}}) + + diff --git a/pages/order/components/date/index.wxss b/pages/order/components/date/index.wxss index 3ce5048..0446023 100644 --- a/pages/order/components/date/index.wxss +++ b/pages/order/components/date/index.wxss @@ -16,14 +16,15 @@ .dates-boxes { display: flex; align-items: center; - padding: 31rpx 21rpx; - border-top: 1rpx solid #ccc; + padding: 31rpx 0; + /* padding: 31rpx 21rpx; */ + /* border-top: 1rpx solid #ccc; */ } .date-item { - width: 162rpx; - height: 97rpx; + width: 120rpx; + height: 133rpx; border-radius: 10rpx; - border: 1rpx solid #333; + /* border: 1rpx solid #333; */ text-align: center; font-size: 27rpx; color: #000; @@ -32,6 +33,8 @@ justify-content: center; align-items: center; flex-direction: column; + background: #F5F5F5; + flex-shrink: 0; } .date-item.active { border-color: #0B898E; @@ -40,7 +43,7 @@ } .date-item.disable { border-color: #CCCCCC; - color: #666; + color: #999; } .date-item .price { font-size: 25rpx; @@ -49,12 +52,27 @@ .date-item.active .price { color: #fff; } +.date-item.active view { + color: #fff; +} .date-item.disable .price { - color: #666; + color: #999; +} +.date-item.disable .short-date { + color: #999; } .more-item { - width: 99rpx; - margin-right: 0; + /* width: 125rpx; */ + /* margin-right: 0; */ + position: absolute; + right: 0; + text-align: center; + padding: 0 26rpx 0 24rpx; + display: flex; + font-weight: 400; + font-size: 27rpx; + color: #0B898E; + align-items: center; } .date-times { display: flex; @@ -63,23 +81,28 @@ margin: 0 21rpx; padding-top: 34rpx; padding-bottom: 10rpx; - border-top: 1rpx dashed #ccc; + /* border-top: 1rpx dashed #ccc; */ flex-wrap: wrap; } .date-time { width: 315rpx; line-height: 58rpx; - border: 1px solid #333; + /* border: 1px solid #333; */ border-radius: 10rpx; text-align: center; font-size: 25rpx; flex-shrink: 0; margin-bottom: 24rpx; color: #000; + background-color: #F5F5F5; } .date-time.disable { - border-color: #ccc; - color: #666666; + /* border-color: #ccc; + color: #666666; */ + background: #F5F5F5; + font-weight: 400; + font-size: 25rpx; + color: #999999; } .date-time.active { border-color: #0B898E; @@ -93,4 +116,9 @@ right: 0; bottom: 0; padding-bottom: 50rpx; +} +.short-date { + font-weight: 500; + font-size: 27rpx; + color: #000000; } \ No newline at end of file diff --git a/pages/order/scene/index.js b/pages/order/scene/index.js index bc4e05c..5a4e20e 100644 --- a/pages/order/scene/index.js +++ b/pages/order/scene/index.js @@ -36,14 +36,19 @@ Page({ is_authentication:1, // 是否实名,0否1是,默认实名 phone:'', //不实名时传的手机号 is_real_name:1, // 是否是一证一票,0否1是, - status:false + status:false, + date: "", + time: "", + ydxz:false, //预定须知弹框 + bookingInfo: null, + bookingInfoTitle: "", + showDate:false, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - this.setData({ product: app.globalData.product, type: options.type, @@ -57,7 +62,11 @@ Page({ is_need_idcard:app.globalData.product.sku.sku_model.is_need_idcard, is_authentication:app.globalData.product.sku.sku_model.is_authentication, is_real_name:app.globalData.product.sku.sku_model.is_real_name, + date: app.globalData.product.date, + time: app.globalData.product.time }) + console.log('-------',this.data.date,this.data.time); + // debugger console.log('-------',app.globalData.product.sku.sku_model.is_need_idcard); console.log('---是否实名----',app.globalData.product.sku.sku_model.is_authentication); console.log('---一证一票----',app.globalData.product.sku.sku_model.is_real_name); @@ -92,6 +101,34 @@ Page({ // showMask:true // }) // }, + // changeDate() { + // this.setData({ + // showDate: true, + // }) + // }, + hideDate: function () { + this.setData({ + showDate: false + }) + }, + showBookingInfo: function (e) { + this.setData({ + bookingInfo: this.data.product.sku.sku_model, + bookingInfoTitle: this.data.product.sku.sku_name + }) + util.pagePoint({ + event: "scene_notice", + param: { + type: this.data.product.type, + id: this.data.product.id + } + }, 1) + }, + closeMask: function () { + this.setData({ + bookingInfo: null + }) + }, showAllPrice:function () { // console.log('detail',app.globalData.product); // console.log('singlePrice',this.data.singlePrice); @@ -255,9 +292,11 @@ Page({ } app.globalData.couponInfo = null; } + app.globalData.product.changeFlag = true this.setData({ date: e.detail, - singlePrice: this.data.gp_id ? this.data.product.sku.event_price : e.detail.price + singlePrice: this.data.gp_id ? this.data.product.sku.event_price : e.detail.price, + showDate:true }) // this.changePrice() }, @@ -290,6 +329,12 @@ Page({ }) }, + changed() { + app.globalData.product.date = this.data.date + app.globalData.product.time = this.data.time + app.globalData.product.changeFlag = true + this.hideDate() + }, order:function() { let linkmanList = this.data.linkmanList, productNum = this.data.productNum, date = this.data.date, time = this.data.time, remark = this.data.remark, product = this.data.product; let linkmanIds = []; diff --git a/pages/order/scene/index.json b/pages/order/scene/index.json index 7514262..17ea59b 100644 --- a/pages/order/scene/index.json +++ b/pages/order/scene/index.json @@ -1,8 +1,10 @@ { "usingComponents": { "title":"/pages/component/TitleHeader", - "date":"../components/date/index", + "date1":"../components/date/index", "contact":"../components/contact/index", - "coupon":"../components/coupon/index" + "coupon":"../components/coupon/index", + "notice":"/pages/component/notice/notice", + "date":"/pages/order/components/date" } } \ No newline at end of file diff --git a/pages/order/scene/index.wxml b/pages/order/scene/index.wxml index 047e151..9197311 100644 --- a/pages/order/scene/index.wxml +++ b/pages/order/scene/index.wxml @@ -1,12 +1,31 @@ - + + + + + + + {{product.product.title}} + + + + {{date.date}} {{date.week}} + + + {{time.start_time}}-{{time.end_time}} 入园 + + + + + 修改 > + - 团体主体名称: @@ -15,11 +34,27 @@ - {{product && product.isGroup!=1?'购票数量':'预约人数'}} - + {{product && product.isGroup!=1?product.sku.sku_name:'预约人数'}} + + + + {{product.sku.price/100}} + + + {{productNum}} - + + + + + + {{item}}| + + 预订须知 > + @@ -93,4 +128,23 @@ + + + + + + + + + + + 合计: {{price}} + + + + 确定 + + + + \ No newline at end of file diff --git a/pages/order/scene/index.wxss b/pages/order/scene/index.wxss index 945fd9b..0cbec31 100644 --- a/pages/order/scene/index.wxss +++ b/pages/order/scene/index.wxss @@ -64,14 +64,14 @@ page { display: flex; align-items: center; padding: 31rpx 21rpx; - border-top: 1rpx solid #ccc; + /* border-top: 1rpx solid #ccc; */ } .date-item { - width: 162rpx; - height: 97rpx; + width: 120rpx; + height: 133rpx; border-radius: 10rpx; - border: 1rpx solid #333; + /* border: 1rpx solid #333; */ text-align: center; font-size: 27rpx; color: #000; @@ -80,6 +80,8 @@ page { justify-content: center; align-items: center; flex-direction: column; + background: #F5F5F5; + flex-shrink: 0; } .date-item.active { @@ -90,7 +92,7 @@ page { .date-item.disable { border-color: #CCCCCC; - color: #666; + color: #999; } .date-item .price { @@ -101,14 +103,29 @@ page { .date-item.active .price { color: #fff; } +.date-item.active view { + color: #fff; +} .date-item.disable .price { - color: #666; + color: #999; +} +.date-item.disable .short-date { + color: #999; } .more-item { - width: 99rpx; - margin-right: 0; + /* width: 99rpx; + margin-right: 0; */ + position: absolute; + right: 0; + text-align: center; + padding: 0 26rpx 0 24rpx; + display: flex; + font-weight: 400; + font-size: 27rpx; + color: #0B898E; + align-items: center; } .date-times { @@ -118,25 +135,35 @@ page { margin: 0 21rpx; padding-top: 34rpx; padding-bottom: 10rpx; - border-top: 1rpx dashed #ccc; + /* border-top: 1rpx dashed #ccc; */ flex-wrap: wrap; } .date-time { width: 315rpx; line-height: 58rpx; - border: 1px solid #333; + /* border: 1px solid #333; */ border-radius: 10rpx; text-align: center; font-size: 25rpx; flex-shrink: 0; margin-bottom: 24rpx; color: #000; + background-color: #F5F5F5; } .date-time.disable { - border-color: #ccc; - color: #666666; + /* border-color: #ccc; + color: #666666; */ + background: #F5F5F5; + font-weight: 400; + font-size: 25rpx; + color: #999999; +} +.short-date { + font-weight: 500; + font-size: 27rpx; + color: #000000; } .date-time.active { @@ -155,9 +182,9 @@ page { font-weight: 500; color: #000; flex-shrink: 0; - width: 67rpx; + /* width: 67rpx; */ line-height: 49rpx; - background: #F0F0F0; + /* background: #F0F0F0; */ border-radius: 7rpx; text-align: center; margin: 0 20rpx; @@ -340,4 +367,82 @@ page { /* margin-bottom: 45%; */ overflow-y: auto; margin: auto; +} +.change-date { + font-weight: 500; + font-size: 27rpx; + color: #0B898E; +} +.text1 { + margin-left: 21rpx; + font-weight: 400; + font-size: 23rpx; + color: #0B898E; + margin-bottom: 21rpx; + display: flex; + align-items: flex-end; + padding-bottom: 40rpx; +} +.text2 { + margin-left: 22rpx; + font-weight: 400; + font-size: 23rpx; + color: #666666; + padding-bottom: 41rpx; +} +.mask-content2 { + position: absolute; + left: 0; + right: 0; + bottom: 0; + width: 100%; + background: white; + border-radius: 12rpx; + overflow-y: auto; +} +.bottom-box { + height: 133rpx; + background: #FFFFFF; + box-shadow: 0rpx -3rpx 8rpx 0rpx rgba(71,71,71,0.1); + padding: 0 50rpx; + display: flex; + justify-content: space-between; + align-items: center; +} +.totalPrice { + font-family: PingFang SC; + font-weight: 500; + font-size: 48rpx; + color: #D62828; +} +.totalPrice::before { + content: "¥"; + font-size: 24rpx; +} +.next { + width: 250rpx; + height: 80rpx; + background: #D62828; + border-radius: 40rpx; + font-family: PingFang; + font-weight: bold; + font-size: 32rpx; + color: #FFFFFF; + text-align: center; + line-height: 80rpx; +} +.icon-close { + position: absolute; + top: 30rpx; + right: 30rpx; +} +.s-price { + font-weight: 500; + font-size: 36rpx; + color: #D62828; + margin-right: 17rpx; +} +.s-price::before { + content: "¥"; + font-size: 24rpx; } \ No newline at end of file