diff --git a/app.js b/app.js index 6645b5f..0eea595 100644 --- a/app.js +++ b/app.js @@ -72,6 +72,7 @@ App({ } }) }, + login() { let that = this; tt.login({ diff --git a/assets/images/location(1).png b/assets/images/location(1).png new file mode 100644 index 0000000..2edc6fb Binary files /dev/null and b/assets/images/location(1).png differ diff --git a/assets/images/location(2).png b/assets/images/location(2).png new file mode 100644 index 0000000..d38a829 Binary files /dev/null and b/assets/images/location(2).png differ diff --git a/assets/images/location(3).png b/assets/images/location(3).png new file mode 100644 index 0000000..75c07e2 Binary files /dev/null and b/assets/images/location(3).png differ diff --git a/assets/images/location(4).png b/assets/images/location(4).png new file mode 100644 index 0000000..0786780 Binary files /dev/null and b/assets/images/location(4).png differ diff --git a/assets/images/location.png b/assets/images/location.png new file mode 100644 index 0000000..ba09320 Binary files /dev/null and b/assets/images/location.png differ diff --git a/assets/itemImg/arrow-right-l.png b/assets/itemImg/arrow-right-l.png new file mode 100644 index 0000000..00392ad Binary files /dev/null and b/assets/itemImg/arrow-right-l.png differ diff --git a/assets/itemImg/arrow-right-l2.png b/assets/itemImg/arrow-right-l2.png new file mode 100644 index 0000000..e7ec491 Binary files /dev/null and b/assets/itemImg/arrow-right-l2.png differ diff --git a/assets/itemImg/arrow-right-l3.png b/assets/itemImg/arrow-right-l3.png new file mode 100644 index 0000000..5524fe1 Binary files /dev/null and b/assets/itemImg/arrow-right-l3.png differ diff --git a/components/banner/index.js b/components/banner/index.js index ce702be..07c650c 100644 --- a/components/banner/index.js +++ b/components/banner/index.js @@ -19,44 +19,45 @@ Component({ data: { bannerUrl: imgurl.banner.url, currentIndex: 0, - mouldType:0, + mouldType: 0, }, /** * 组件的方法列表 */ methods: { - gotobannerdetail: function(e) { - + gotobannerdetail: function (e) { + console.log(e, 'e'); + console.log(this.data.list) if (e.currentTarget.dataset.data.type == 3) { // 小程序路径 let indexOf = (e.currentTarget.dataset.data.pagePath).indexOf("="); console.log(indexOf, "123") let id = (e.currentTarget.dataset.data.pagePath).substr(indexOf); - console.log(id.split("="),123); - let type = (e.currentTarget.dataset.data.pagePath).substr(indexOf + 1, 2)// 2020/7/22 变量获取pagePath中的type + console.log(id.split("="), 123); + let type = (e.currentTarget.dataset.data.pagePath).substr(indexOf + 1, 2) // 2020/7/22 变量获取pagePath中的type console.log(indexOf, id, type); console.log(e.currentTarget.dataset.data.pagePath) - if(type == 'cd' || type == 'sd'){ + if (type == 'cd' || type == 'sd') { tt.navigateTo({ url: `/${e.currentTarget.dataset.data.pagePath}`, }) - }else if(type == "wj"){ + } else if (type == "wj") { tt.navigateTo({ - url: `/pages/questionnaire/questionnaire?id=`+id.split("=")[2], + url: `/pages/questionnaire/questionnaire?id=` + id.split("=")[2], }) - }else if (type == 'ra'){ + } else if (type == 'ra') { tt.navigateTo({ - url: `/pages/radetail/index?id=`+id.split("=")[2], + url: `/pages/radetail/index?id=` + id.split("=")[2], }) } - }else if(e.currentTarget.dataset.data.type==2){ + } else if (e.currentTarget.dataset.data.type == 2) { // 自由图文 tt.navigateTo({ url: `/pages/freeBannerDetail/index?id=${e.currentTarget.dataset.id}` }); - }else if(e.currentTarget.dataset.data.type==4){ + } else if (e.currentTarget.dataset.data.type == 4) { tt.navigateToMiniProgram({ appId: e.currentTarget.dataset.data.goAppid, // path: 'page/index/index?id=123', @@ -68,11 +69,10 @@ Component({ // 打开成功 } }) - } - else{ + } else { // 固定格式 tt.navigateTo({ - url: `/pages/bannerdetail/bannerdetail?id=${e.currentTarget.dataset.id}` + url: `/pages/bannerdetail/bannerdetail?id=${e.currentTarget.dataset.id}&mallTenantId=${e.currentTarget.dataset.data.tenantId}` }); } }, @@ -84,10 +84,10 @@ Component({ }, attached: function () { // 在组件实例进入页面节点树时执行 - if (app.globalData.mouldType){ + if (app.globalData.mouldType) { this.setData({ mouldType: app.globalData.mouldType }) } }, -}); +}); \ No newline at end of file diff --git a/components/coupons/index.js b/components/coupons/index.js index a2c675f..8c0cf3e 100644 --- a/components/coupons/index.js +++ b/components/coupons/index.js @@ -28,13 +28,16 @@ Component({ }, methods: { gotoDetail(e) { + + console.log(e, 'e'); let couponId = e.currentTarget.dataset.couponid; let title = e.currentTarget.dataset.title; let id = e.currentTarget.dataset.id; let targetAd = e.currentTarget.dataset.targetad; + let mallTenantId = e.currentTarget.dataset.malltenantid; if (id && targetAd != 7) { tt.navigateTo({ - url: `/pages/coupon/detail/index?couponChannelId=${id}&couponId=${couponId}&title=${title}`, + url: `/pages/coupon/detail/index?couponChannelId=${id}&couponId=${couponId}&title=${title}&mallTenantId=${mallTenantId}`, }) } else if (targetAd == 7) { tt.navigateTo({ diff --git a/components/coupons/index.ttml b/components/coupons/index.ttml index f2cc4cd..35148ac 100644 --- a/components/coupons/index.ttml +++ b/components/coupons/index.ttml @@ -1,5 +1,5 @@ + data-couponId='{{data.couponId}}' data-title='{{data.title}}' data-malltenantid='{{data.tenantId}}'> 预售 @@ -23,8 +23,8 @@ {{data.title}} {{data.subTitle}} - - ¥{{data.salePriceStr}} + + ¥{{data.salePriceStr}} ¥ @@ -61,8 +61,9 @@ - 免费领 + 免费领 + 购买 @@ -79,8 +80,9 @@ - 免费领 + 免费领 + 购买 diff --git a/components/optimization/optimization.js b/components/optimization/optimization.js index c51412f..6a1aa1a 100644 --- a/components/optimization/optimization.js +++ b/components/optimization/optimization.js @@ -4,9 +4,9 @@ Component({ * 组件的属性列表 */ properties: { - businessList:{ - type:Array, - value:[] + businessList: { + type: Array, + value: [] }, businessData: { type: Array, @@ -18,39 +18,40 @@ Component({ * 组件的初始数据 */ data: { - classIndex:0 + classIndex: 0 }, /** * 组件的方法列表 */ methods: { - goDetail(e){ + goDetail(e) { let couponChannelId = e.currentTarget.dataset.id let couponId = e.currentTarget.dataset.couponid + let mallTenantId = e.currentTarget.dataset.malltenantid tt.navigateTo({ - url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}&couponId=${couponId}`, + url: `/pages/coupon/detail/index?couponChannelId=${couponChannelId}&couponId=${couponId}&mallTenantId=${mallTenantId}`, }) }, - setIndex(e){ + setIndex(e) { let index = e.currentTarget.dataset.index let id = e.currentTarget.dataset.id - this.triggerEvent('businessid',id) + this.triggerEvent('businessid', id) this.setData({ - classIndex:index + classIndex: index }) }, - goLsit(){ + goLsit() { tt.navigateTo({ url: '/pages/liveLsit/liveLsit', success: (res) => { - + }, fail: (res) => { - + }, }); } } -}) +}) \ No newline at end of file diff --git a/components/optimization/optimization.ttml b/components/optimization/optimization.ttml index 6c46bbc..e117c03 100644 --- a/components/optimization/optimization.ttml +++ b/components/optimization/optimization.ttml @@ -1,31 +1,33 @@ - - 优选好物 - Preferred Good - - - - - - - - - {{item.title}} - - + + 优选好物 + Preferred Good + + + + + + + + + {{item.title}} + - - - - - - - - - {{item.title}} + + - - - + + + + ¥{{item.salePriceStr?item.salePriceStr:""}} - ¥{{item.salePriceStr?item.salePriceStr:""}} - - - 马上抢 - - - - + 马上抢 + + + + + - \ No newline at end of file + + \ No newline at end of file diff --git a/index/index.js b/index/index.js index de99a0c..76236f2 100644 --- a/index/index.js +++ b/index/index.js @@ -117,7 +117,8 @@ Page({ currentMall: '富茂广场', shopList: [], mallTenantId: tt.getStorageSync('mallTenantId') || '', - index: tt.getStorageSync('mallIndex') || 0 + index: tt.getStorageSync('mallIndex') || 0, + locateData: {} }, getCongig() { //获取小程序是否开通授权手机号 @@ -133,19 +134,25 @@ Page({ }) }, + mallSync() { + this.setData({ + mallTenantId: tt.getStorageSync('mallTenantId') || '', + index: tt.getStorageSync('mallIndex') || 0, + }) + }, + getsubMallList() { Http.get({ url: '/mall/subMall?isAll=1', }).then(res => { this.setData({ shopList: res.data, - mallTenantId: res.data[0].tenantId + mallTenantId: tt.getStorageSync('mallTenantId') || res.data[0].tenantId }); - const index = this.data.index - const mallTenantId = this.data.shopList[index].tenantId - tt.setStorageSync('mallTenantId', mallTenantId) - tt.setStorageSync('mallIndex', index) - Http.setMallTenantId(mallTenantId); + if (!tt.getStorageSync('mallTenantId') && res.data.length > 1) { + tt.setStorageSync('mallTenantId', res.data[0].tenantId) + tt.setStorageSync('mallIndex', 0) + } }).catch(err => { console.log(err, 'err'); }) @@ -159,9 +166,11 @@ Page({ this.setData({ index: index, mallTenantId: mallTenantId, - allow_load: true + }); - Http.setMallTenantId(mallTenantId); + this.getBannerlist(); + this.getBusinessList() + this.getCouponChannelList(0) }, getBusineData(e) { @@ -176,7 +185,8 @@ Page({ Http.get({ url: config.api.businessList, data: { - filter: 2 + filter: 2, + mallTenantId: this.data.mallTenantId, } }).then(res => { this.setData({ @@ -206,14 +216,16 @@ Page({ param = { pageNum: this.data.businePageNum, pageSize: 6, - targetAd: 101 + targetAd: 101, + mallTenantId: this.data.mallTenantId, } } else { param = { pageNum: this.data.businePageNum, pageSize: 6, business: key, - targetAd: 101 + targetAd: 101, + mallTenantId: this.data.mallTenantId, } } @@ -579,9 +591,6 @@ Page({ // util.barcode("barcode", optionss.quancode, 510, 100); // console.log(Http.headers.token, "?") this.getLocation() - setTimeout(() => { - this.getsubMallList() - }, 1000) }, /** * 获得经纬度 @@ -593,6 +602,13 @@ Page({ // isHighAccuracy: true, success: function (res) { console.log(res, 'getLocation') + const locateData = { + latitude: res.latitude, + longitude: res.longitude, + } + that.setData({ + locateData: locateData + }) if (res && res.longitude && res.latitude) { Http.post({ url: config.api.updateLBS, @@ -616,9 +632,45 @@ Page({ }, + /** + * @description:根据经纬度计算距离 + * @param {*} locationInfo (lat1, lng1, lat2, lng2) + * @return: distanceObj: { distance , distance_str } + */ + getDistances(lat1, lng1, lat2, lng2) { + + function rad(d) { + return d * Math.PI / 180.0; + } + var radLat1 = rad(lat1); + var radLat2 = rad(lat2); + var a = radLat1 - radLat2; + var b = rad(lng1) - rad(lng2); + var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); + s = s * 6378.137; + s = Math.round(s * 10000) / 10000; + + var distance = s; + var distance_str = ""; + + if (parseInt(distance) >= 1) { + distance_str = distance.toFixed(2) + "km"; + } else { + distance_str = (distance * 1000).toFixed(2) + "m"; + } + + let objData = { + distance: distance, + distance_str: distance_str + } + return objData + }, + onShow: function () { + this.mallSync() console.log(app.globalData.mouldType, "mouldType") // tt.requestSubscribeMessage({ // tmplIds: [], // 需要填入开放平台申请的模版id,支持最多3个同类型模版 @@ -781,6 +833,7 @@ Page({ var that = this; if (app.globalData.token) { + that.getsubMallList() // 登录 console.log(app.globalData.token) that.getCongig() //获取小程序是否开通授权手机号 @@ -808,7 +861,7 @@ Page({ that.topicShowall(6); that.getBusinessList(); that.getCouponChannelList(0) - + that.getsubMallList() that.getType() that.uesrInfo() @@ -857,6 +910,7 @@ Page({ } else { app.tokenCallback = token => { + that.getsubMallList() // 登录 console.log(app.globalData.token) that.getCongig() //获取小程序是否开通授权手机号 @@ -881,6 +935,7 @@ Page({ that.topicShowall(5); that.topicShowall(6); that.getBusinessList(); + that.getCouponChannelList(0) that.getType() that.uesrInfo() @@ -1054,7 +1109,8 @@ Page({ data: { pageNum: 1, pageSize: 7, - plat: 3 + plat: 3, + mallTenantId: tt.getStorageSync('mallTenantId') || "" } }).then(res => { that.getmemberId(app.globalData.token); diff --git a/index/index.ttml b/index/index.ttml index dac2020..40e707d 100644 --- a/index/index.ttml +++ b/index/index.ttml @@ -22,7 +22,9 @@ disabled="{{false}}"> - 当前广场:{{ shopList[index].name }} ↓ + + {{ shopList[index].name }} + diff --git a/index/index.ttss b/index/index.ttss index a453295..e896974 100644 --- a/index/index.ttss +++ b/index/index.ttss @@ -118,16 +118,25 @@ page { .pickerMall { height: auto; - margin: 10rpx 0 15rpx 10rpx; + margin: 0 0 15rpx 20rpx; + font-size: 30rpx; } +.location { + position: relative; + top: 8rpx; + width: 35rpx; + height: 35rpx; + margin-right: 10rpx; +} -.underlingImg { - width: 30rpx; - height: 60rpx; - font-size: 30prx; - float: left; - /* margin-top: 20rpx; */ + +.right { + position: relative; + top: 6rpx; + left: 10rpx; + width: 35rpx; + height: 35rpx; } .underlingName { diff --git a/index/searchbar.js b/index/searchbar.js index d5ca1c7..a191f67 100644 --- a/index/searchbar.js +++ b/index/searchbar.js @@ -11,7 +11,7 @@ Page({ data: { navigationBarHeight, navLineHeight: ((app.statusBarHeight + app.statusBarHeight) + 50) + "px", - navImgHeight:(((app.statusBarHeight + app.statusBarHeight) + 34)/2) + "px", + navImgHeight: (((app.statusBarHeight + app.statusBarHeight) + 34) / 2) + "px", lists: [], merchantVoList: [], indexId: 0, @@ -23,11 +23,11 @@ Page({ teljpgUrl: imgurl.teljpg.url, map: imgurl.map.url, //商场地图 mapUrl: '/pages/marketAtlas/marketAtlas', //跳转地图的路径 - mouldType:0, + mouldType: 0, }, getFemgMap() { //判断时候对接封了地图 Http.get({ - url: config.api.ifFengMap + url: config.api.ifFengMap + `?mallTenantId=${tt.getStorageSync('mallTenantId')||""}` }).then(res => { if (res.data) { // let initMpa = { @@ -82,13 +82,13 @@ Page({ */ gotoDetail(e) { tt.navigateTo({ - url: `/pages/index/searchbar/detail/index?id=${e.currentTarget.dataset.id}` + url: `/pages/index/searchbar/detail/index?id=${e.currentTarget.dataset.id}&mallTenantId=${tt.getStorageSync('mallTenantId') || ""}` }) }, /** * 生命周期函数--监听页面加载 */ - onLoad: function(options) { + onLoad: function (options) { this.setData({ mouldType: app.globalData.mouldType, }) @@ -112,19 +112,20 @@ Page({ }) }; tt.getSystemInfo({ - success: function(res) { + success: function (res) { that.setData({ windowHeight: res.windowHeight }) }, }) }, - getBussiness: function() { + getBussiness: function () { let that = this; Http.get({ url: config.api.businessList, data: { - filter: 1 + filter: 1, + mallTenantId: tt.getStorageSync('mallTenantId') || "" } }).then(res => { that.setData({ @@ -144,19 +145,21 @@ Page({ }); }) }, - getList: function(page, businessId) { + getList: function (page, businessId) { let that = this; let data; if (businessId == 0) { data = { pageNum: page, - pageSize: 8 + pageSize: 8, + mallTenantId: tt.getStorageSync('mallTenantId') || "" } } else { data = { pageNum: page, pageSize: 8, - businessId: businessId + businessId: businessId, + mallTenantId: tt.getStorageSync('mallTenantId') || "" } } Http.get({ @@ -189,7 +192,7 @@ Page({ }); }) }, - phone: function(e) { + phone: function (e) { let that = this; if (e.currentTarget.dataset.merchantlinkphone) { tt.makePhoneCall({ @@ -200,7 +203,7 @@ Page({ /** * 页面上拉触底事件的处理函数 */ - onReachBottom: function() { + onReachBottom: function () { let that = this; that.data.page++; that.setData({ diff --git a/pages/bannerdetail/bannerdetail.js b/pages/bannerdetail/bannerdetail.js index 1bc5234..fec2c96 100644 --- a/pages/bannerdetail/bannerdetail.js +++ b/pages/bannerdetail/bannerdetail.js @@ -22,14 +22,15 @@ Page({ mouldType: app.globalData.mouldType, }) let that = this; - if (options.id){ + if (options.id) { Http.get({ url: config.api.bannerDetail, data: { - id: options.id + id: options.id, + mallTenantId: options.mallTenantId, } }).then(res => { - if(res.data.type==2){ + if (res.data.type == 2) { that.setData({ nodes: res.data.html }) @@ -52,4 +53,4 @@ Page({ url: '/index/index', }) }, -}); +}); \ No newline at end of file diff --git a/pages/coupon/detail/index.js b/pages/coupon/detail/index.js index 515ee7d..f91679e 100644 --- a/pages/coupon/detail/index.js +++ b/pages/coupon/detail/index.js @@ -560,7 +560,8 @@ Page({ Http.get({ url: config.api.getSpuid, data: { - id: id + id: id, + mallTenantId: this.data.mallTenantId || '' } }).then(res => { if (res.data) { diff --git a/pages/index/searchbar/detail/index.js b/pages/index/searchbar/detail/index.js index 803597c..47af965 100644 --- a/pages/index/searchbar/detail/index.js +++ b/pages/index/searchbar/detail/index.js @@ -200,6 +200,7 @@ Page({ url: config.api.listByMerchant, data: data }).then(res => { + console.log(res, 'res'); that.setData({ couponList: res.data.page.list, }) diff --git a/pages/order/index/index.js b/pages/order/index/index.js index 1d24452..1234bf9 100644 --- a/pages/order/index/index.js +++ b/pages/order/index/index.js @@ -41,8 +41,8 @@ Page({ canIUse: tt.canIUse("button.open-type.getPhoneNumber"), //判断小程序是否能用获取手机插件 ifshowtab: null, shopList: [], - index: 0, - mallTenantId: '' + mallTenantId: tt.getStorageSync('mallTenantId') || '', + index: tt.getStorageSync('mallIndex') || 0 }, setPhone(paramData) { //子组件调用这个方法说明手机号已经授权成功 @@ -79,8 +79,8 @@ Page({ bindPickerChange(e) { const index = e.detail.value const mallTenantId = this.data.shopList[index].tenantId - // tt.setStorageSync('mallTenantId', mallTenantId) - // tt.setStorageSync('mallIndex', index) + tt.setStorageSync('mallTenantId', mallTenantId) + tt.setStorageSync('mallIndex', index) this.setData({ index: index, mallTenantId: mallTenantId, @@ -95,14 +95,21 @@ Page({ url: '/index/index', }) }, + + mallSync() { + this.setData({ + mallTenantId: tt.getStorageSync('mallTenantId') || '', + index: tt.getStorageSync('mallIndex') || 0, + }) + }, + onLoad(e) { Http.get({ url: '/mall/subMall?isAll=1', }).then(res => { this.setData({ shopList: res.data, - // tt.getStorageSync('mallTenantId') || - mallTenantId: res.data[0].tenantId + mallTenantId: tt.getStorageSync('mallTenantId') || res.data[0].tenantId }); console.log(this.data.shopList, 'list'); @@ -111,6 +118,7 @@ Page({ }) }, onShow() { + this.mallSync() this.getList(this.data.boatFlag, 1); Http.get({ url: config.api.checkUserStatus, diff --git a/utils/HttpBasics.js b/utils/HttpBasics.js index 0516240..577a1f9 100644 --- a/utils/HttpBasics.js +++ b/utils/HttpBasics.js @@ -21,7 +21,6 @@ class HttpBasics { headers = { "Content-Type": "application/json;charset=UTF-8", token: "", - mallTenantId: "" // token:"3ab2afa2-f704-4086-b6e5-ad0715c7e2a1:1027:tt-cuser" }; @@ -33,13 +32,13 @@ class HttpBasics { this.headers.token = token; } - /** - * @description 设置mallTenantId - * @param {*} mallTenantId - */ - setMallTenantId(mallTenantId) { - this.headers.mallTenantId = mallTenantId; - } + // /** + // * @description 设置mallTenantId + // * @param {*} mallTenantId + // */ + // setMallTenantId(mallTenantId) { + // this.headers.mallTenantId = mallTenantId; + // } /** * 获取数据