Commit b699bef8 by 程智春

基础组件

parent d18b7cad
......@@ -16,5 +16,8 @@ console.log(process.env,'-----------------config------')
forward(data) {
return requestPOST(`${process.env.OLSHOP_URL}/article/forward`, data)
},
queryLocation(longitude,latitude){
return requestGET(`${process.env.OLSHOP_URL}/operatingArea/query_Location_operating_area_area_list?location=${longitude},${latitude}`)
}
}
\ No newline at end of file
......@@ -5,6 +5,7 @@ import "../static/nicon/iconfont.css"
import goodsApi from "./api/goods"
import orderApi from "./api/order"
import promoteApi from "./api/promote";
import indexApi from './api/index'
import { DFSImg } from "@/utils/index";
import { $themeToLink } from "@/utils/mayi"
......@@ -47,4 +48,24 @@ mpApp.$themeToLink = $themeToLink
mpApp.goodsApi = goodsApi;
mpApp.orderApi = orderApi;
mpApp.promoteApi = promoteApi;
mpApp.indexApi = indexApi;
mpApp.DFSImg = DFSImg;
if (!mpApp.globalData.setPopupStorage){
let popUpList = wx.getStorageSync('popUpList') || []
let arr = []
popUpList.forEach(item=> {
arr.push(item)
wx.removeStorageSync(item)
})
arr.forEach(item => {
popUpList.splice(popUpList.indexOf(item),1)
})
wx.setStorageSync('popUpList', popUpList)
}
\ No newline at end of file
......@@ -34,6 +34,15 @@
<div v-if="item.componentCode == 'float-button'">
<float-button :datas="item"></float-button>
</div>
<div v-if="item.componentCode == 'goods-search'">
<goods-search :datas="item"></goods-search>
</div>
<div v-if="item.componentCode == 'notice'">
<notice :datas="item"></notice>
</div>
<div v-if="item.componentCode == 'pop-up'">
<pop-up :datas="item"></pop-up>
</div>
</div>
</scroll-view>
<!-- <image
......
......@@ -7,7 +7,10 @@
"van-button": "/static/vant/button/index",
"area-navigation":"/static/nativeComponents/AreaNavigation/index",
"cube-nav":"/static/nativeComponents/CubeNav/index",
"float-button":"/static/nativeComponents/FloatButton/index"
"float-button":"/static/nativeComponents/FloatButton/index",
"goods-search":"/static/nativeComponents/GoodsSearch/index",
"notice":"/static/nativeComponents/Notice/index",
"pop-up":"/static/nativeComponents/PopUp/index"
},
"enablePullDownRefresh":true
}
\ No newline at end of file
......@@ -46,7 +46,7 @@ export function getQueryVariable(query,variable) {
}
//补全图片路径
export function DFSImg(path, w, h) { //
export function DFSImg(path, w, h,type=0) { //
// if (path == null || path == '') {
// return require('~/static/images/noImg.png');
// }
......@@ -57,7 +57,12 @@ export function DFSImg(path, w, h) { //
if (h) style += ',h_' + h;
if (style.length > 0) {
if(path.indexOf('?x-oss-process') == -1){
path += '?x-oss-process=image/resize,m_pad,limit_0' + style
if(type == 1){
path += '?x-oss-process=image/resize,limit_0' + style
}else{
path += '?x-oss-process=image/resize,m_pad,limit_0' + style
}
}
}
if (path.indexOf('http') == 0) {
......
// static/nativeComponents/AreaNavigation/index.js
const app = getApp()
const { indexApi } = app;
Component({
/**
* 组件的属性列表
......@@ -57,79 +58,51 @@ Component({
const latitude = res.latitude
const longitude = res.longitude
console.log('组件2', _this.data.designateAreaObj)
wx.request({
url: `http://test-m-shop.mayi888.cn/test/innerApi/shopApiService/operatingArea/query_Location_operating_area_area_list?location=${longitude},${latitude}`,
header: {
'Shop-Mixid': 'Id9uwD'
},
success(data) {
console.log('组件3', _this.data.designateAreaObj)
if (data.data.code == '200') {
let city = ''
data.data.data.forEach(item => {
if (item.operatingAreaAreaId) {
city = item;
}
})
if (city == '') {
_this.setData({
positionCity: data.data.data[0]
})
} else {
_this.setData({
positionCity: city
})
indexApi.queryLocation(longitude, latitude).then(data => {
if (data.data.code == '200') {
let city = ''
data.data.data.forEach(item => {
if (item.operatingAreaAreaId) {
city = item;
}
console.log(_this.data.positionCity, '定位城市信息')
console.log(_this.data.designateAreaObj,'组件信息')
let str = JSON.stringify({
id: _this.data.positionCity.operatingAreaAreaId,
regionName: _this.data.positionCity.regionName,
regionType: _this.data.positionCity.regionType,
systemRegionId: _this.data.positionCity.systemRegionId,
outId: _this.data.positionCity.outId,
areaGroupId: _this.data.positionCity.areaGroupId,
})
if (city == '') {
_this.setData({
positionCity: data.data.data[0]
})
} else {
_this.setData({
positionCity: city
})
console.log(str,'str.......')
wx.setStorageSync('location', str)
}
if (_this.data.positionCity.operatingAreaAreaId == _this.data.designateAreaObj.id){
_this.setData({
positionName: _this.data.positionCity.regionName
})
}else{
_this.setData({
changeShow : true
})
}
console.log(_this.data.positionCity, '定位城市信息')
console.log(_this.data.designateAreaObj, '组件信息')
let str = JSON.stringify({
id: _this.data.positionCity.operatingAreaAreaId,
regionName: _this.data.positionCity.regionName,
regionType: _this.data.positionCity.regionType,
systemRegionId: _this.data.positionCity.systemRegionId,
outId: _this.data.positionCity.outId,
areaGroupId: _this.data.positionCity.areaGroupId,
})
console.log(str, 'str.......')
wx.setStorageSync('location', str)
if (_this.data.positionCity.operatingAreaAreaId == _this.data.designateAreaObj.id) {
_this.setData({
positionName: _this.data.positionCity.regionName
})
} else {
if (!wx.getStorageSync('location')) {
if (_this.data.designateAreaObj.id) {
_this.setData({
changeShow: true
})
}
wx.setStorageSync('location', JSON.stringify({
id: _this.data.designateAreaObj.id,
regionName: _this.data.designateAreaObj.regionName,
regionType: _this.data.designateAreaObj.regionType,
systemRegionId: _this.data.designateAreaObj.systemRegionId,
areaGroupId: _this.data.designateAreaObj.areaGroupId,
outId: _this.data.designateAreaObj.outId
}))
_this.setData({
positionName: _this.data.designateAreaObj.regionName
})
}
}
}
},
fail(){
console.log('定位')
} else {
if (!wx.getStorageSync('location')) {
if (_this.data.designateAreaObj.id) {
......@@ -148,8 +121,26 @@ Component({
}
}
}
})
}).catch(err => {
console.log('定位')
if (!wx.getStorageSync('location')) {
if (_this.data.designateAreaObj.id) {
wx.setStorageSync('location', JSON.stringify({
id: _this.data.designateAreaObj.id,
regionName: _this.data.designateAreaObj.regionName,
regionType: _this.data.designateAreaObj.regionType,
systemRegionId: _this.data.designateAreaObj.systemRegionId,
areaGroupId: _this.data.designateAreaObj.areaGroupId,
outId: _this.data.designateAreaObj.outId
}))
_this.setData({
positionName: _this.data.designateAreaObj.regionName
})
}
}
})
},
fail(error) {
console.log('定位失败')
......
......@@ -36,7 +36,6 @@
show="{{noShow}}"
use-slot
showConfirmButton="{{false}}"
class="change-dialog"
>
<view class="change-dialog">
<view style="line-height:60rpx">您所在的地区暂未开放</view>
......@@ -48,7 +47,6 @@
show="{{changeShow}}"
use-slot
showConfirmButton="{{false}}"
class="change-dialog"
>
<view class="change-dialog">
<view style="line-height:60rpx">
......
......@@ -10,7 +10,7 @@
></i>
<i
wx:else
class="content-img antt iconfont {{datas.componentData.icon.src}}"
class="content-img iconfont {{datas.componentData.icon.src}}"
style="font-size:1.6em;color:{{datas.componentData['contentColor']}}"
>
</i>
......
// static/nativeComponents/GoodsSearch/index.js
let app = getApp()
Component({
/**
* 组件的属性列表
*/
properties: {
datas: {
type: Object
}
},
/**
* 组件的初始数据
*/
data: {
backgroundColor : '',
borderColor : '',
placeholderValue : ''
},
ready(){
this.setData({
backgroundColor: this.data.datas.componentData["showStyle"] == 1 &&
this.data.datas.componentData["backgroundColorShow"] ? this.data.datas.componentData["backgroundColor"] : "rgba(224, 224, 224, 0)",
})
if (this.data.datas.componentData["showStyle"] == 0){
this.setData({
borderColor : this.data.datas.componentData["borderColorShow"]
? this.data.datas.componentData["borderColor"]
: "rgba(224, 224, 224, 0)"
})
}else{
this.setData({
borderColor: 'transparent'
})
}
this.setData({
placeholderValue: this.data.datas.componentData.placeHolderVal ? this.data.datas.componentData.placeHolderVal : '搜索店铺内商品'
})
},
/**
* 组件的方法列表
*/
methods: {
toSearchPage(){
app.$themeToLink({
type: 1,
link: '/goodsSearch/goodsSearch?placeHolderText=' + (this.data.datas.componentData["placeHolderVal"] || '')
})
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--static/nativeComponents/GoodsSearch/index.wxml-->
<view class="goods-search flex" style="background:{{datas.componentData.heapBgColor||''}}">
<view class="ipt flex {{datas.componentData.keywordPosition == 1 ? 'textCenter' : ''}} {{datas.componentData.showStyle == 0 ? 'my-hairline--all' :''}}" style="border-radius:{{2*(datas.componentData['radius']/100)*2}}em;border-radius:{{2*(datas.componentData['radius']/100)}}em;background:{{backgroundColor}};border-color:{{borderColor}}" bindtap="toSearchPage">
<i class="iconfont-common common-iconsousuo"></i>
<input style="width:{{placeholderValue.length*40}}rpx" disabled type="text" placeholder="{{placeholderValue}}">
</input>
</view>
</view>
/* static/nativeComponents/GoodsSearch/index.wxss */
@import "/static/font/common_icon.wxss";
.flex{
display: flex;
}
.goods-search{
font-size: 24rpx;
width: 100%;
height: 80rpx;
align-items:center;
}
.goods-search i{
margin: 0 20rpx;
color: #bbb;
}
.goods-search .ipt{
width: 96%;
margin: 0 auto;
height: 60rpx;
align-items: center;
position: relative;
border-width: 1rpx;
border-style: solid;
}
.goods-search .ipt input{
font-size: 28rpx;
color: #bbb;
}
.goods-search .textCenter{
justify-content: center;
}
// static/nativeComponents/Notice/index.js
let app = getApp()
Component({
/**
* 组件的属性列表
*/
properties: {
datas : {
type : Object
}
},
/**
* 组件的初始数据
*/
data: {
timer:null,
newLeft : 0
},
ready(){
let marqueeWidth = 0;
let screenWidth = 0;
let _this = this
this.createSelectorQuery().select('.marquee').boundingClientRect(function(res){
if (res) {
marqueeWidth = res.width
_this.createSelectorQuery().select('.notice').boundingClientRect(function (res1) {
if (res1) {
screenWidth = res1.width
console.log(marqueeWidth, screenWidth, 'screenWidth')
if (marqueeWidth > screenWidth) {
_this.marqueeMove(marqueeWidth,screenWidth);
}else{
clearInterval(_this.data.timer);
_this.setData({
newLeft : 0
})
}
}
}).exec()
}
}).exec()
},
/**
* 组件的方法列表
*/
methods: {
marqueeMove(marqueeWidth,screenWidth){
clearInterval(this.data.timer);
this.data.timer = setInterval(() => {
this.setData({
newLeft : this.data.newLeft - 1
})
if(Math.abs(this.data.newLeft) >= marqueeWidth + 200){
this.setData({
newLeft: screenWidth
})
}
},10)
},
onclickHandle(){
app.$themeToLink(this.data.datas.componentData.link)
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--static/nativeComponents/Notice/index.wxml-->
<view class="notice-wrap" style="background-color:{{datas.componentData.backgroundColor}}">
<view class="notice" style="text-align:left;color:{{datas.componentData.fontColor}}; ">
<view class="marquee" style="left:{{newLeft * 2}}rpx" bindtap="onclickHandle">{{datas.componentData.content}}</view>
</view>
</view>
/* static/nativeComponents/Notice/index.wxss */
.notice{
font-size: 32rpx;
position: relative;
overflow: hidden;
height: 80rpx;
width: calc(100vw - 40rpx);
margin-left: 20rpx;
}
.marquee {
position: absolute;
height: 80rpx;
line-height: 80rpx;
/* width: 100%; */
margin: 0 auto;
white-space: nowrap;
box-sizing: border-box;
}
\ No newline at end of file
// static/nativeComponents/PopUp/index.js
let app = getApp()
Component({
/**
* 组件的属性列表
*/
properties: {
datas:{
type:Object
}
},
/**
* 组件的初始数据
*/
data: {
timeout: null,
domainShow: false,
img : ''
},
detached(){
clearTimeout(this.data.timeout);
},
ready() {
this.setData({
img: app.DFSImg(this.data.datas.componentData.imageUrl,700,null,1)
})
if (this.getPopFlag() == 'true'){
this.setData({
domainShow : false
})
}else{
this.setData({
domainShow: true
})
if (this.data.datas.componentData.columnNum > 0 && this.data.datas.componentData.autoOff){
clearTimeout(this.data.timeout);
this.data.timeout = setTimeout(() => {
this.setData({
domainShow: false
})
this.setPopFlag('true')
}, this.data.datas.componentData.columnNum * 1000)
}
}
},
/**
* 组件的方法列表
*/
methods: {
getPopFlag() {
let routes = getCurrentPages()
let page = routes[routes.length - 1].route
return wx.getStorageSync(`${app.globalData.shopInfo.shopCode}_popFlag_${page}_${this.data.datas.id}`)
},
setPopFlag(value) {
app.globalData.setPopupStorage = 1;
let routes = getCurrentPages()
let page = routes[routes.length - 1].route
wx.setStorageSync(`${app.globalData.shopInfo.shopCode}_popFlag_${page}_${this.data.datas.id}`, value)
let popUpList = wx.getStorageSync('popUpList') || [];
popUpList.push(`${app.globalData.shopInfo.shopCode}_popFlag_${page}_${this.data.datas.id}`)
wx.setStorageSync('popUpList', popUpList)
console.log(app.globalData)
},
backHandle(){
this.setData({
domainShow : false
})
this.setPopFlag("true");
clearTimeout(this.data.timeout);
},
onclickHandle() {
app.$themeToLink(this.data.datas.componentData.link);
}
}
})
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<!--static/nativeComponents/PopUp/index.wxml-->
<view class="pop-up" wx:if="{{domainShow}}">
<view class="shade"></view>
<view class="content">
<image src="{{img}}" bindtap="onclickHandle"></image>
<view class="back {{datas.componentData.backButtonSite=='bottom'?'back-bottom':'back-top'}}" bindtap="backHandle">
<em></em>
<em></em>
</view>
</view>
</view>
/* static/nativeComponents/PopUp/index.wxss */
.pop-up{
font-size: 20rpx;
position: fixed;
left: 0;
top: 0;
z-index: 5000;
width: 100%;
height: 100%;
}
.shade {
opacity: 0.7;
background-color: #000;
width: 100vw;
height: 100vh;
}
.content{
z-index: 5001;
width: 80%;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.content image{
width: 100%
}
.content .back{
width: 48rpx;
height: 48rpx;
}
.content .back em{
display: block;
width: 100%;
height: 4rpx;
background-color: #fff;
margin-top: 20rpx;
box-shadow: 0 0 1rpx #fff;
}
em:nth-child(1) {
transform: translateY(0em) rotate(45deg);
}
em:nth-child(2) {
transform: translateY(-1.2em) rotate(-45deg);
}
.back-bottom {
margin: 40rpx auto 0;
}
.back-top {
position: absolute;
top: 20rpx;
right: 24rpx;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment