修改小程序与app的兼容文件

This commit is contained in:
gaoxs
2020-04-06 17:18:09 +08:00
parent c837a94363
commit 57ae931f2d
31 changed files with 1257 additions and 1101 deletions

View File

@ -45,7 +45,7 @@ export default {
console.log(this.$store.getters.userInfo, '获取store里面的 userInfo');
cookie.get("spread");
// this.toLaunch();
if (this.$deviceType == 'App') {
if (this.$deviceType == 'app') {
// this.toLaunch();
this.$yrouter.switchTab({
path: '/pages/home/index',

View File

@ -1,6 +1,6 @@
<template>
<view class="container">
<view v-if="!$store.getters.token&&$deviceType=='Weixin'">
<view v-if="!$store.getters.token&&$deviceType=='weixin'">
<view class="getUserInfo">
<text>您还未允许微信登录授权请点击下方按钮允许微信授权登录</text>
<button type="primary" open-type="getUserInfo" @getuserinfo="getUserInfo">允许微信登录授权</button>
@ -8,7 +8,7 @@
<button @click="back">取消微信登录授权</button>
</view>
</view>
<view v-if="!$store.getters.token&&$deviceType!='Weixin'">
<view v-if="!$store.getters.token&&$deviceType!='weixin'&&$deviceType=='app'">
<view class="getUserInfo">
<text>请先登录</text>
<button type="primary" @click="this.toLogin">去登录</button>
@ -42,7 +42,8 @@
computed: {
...mapState(["isAuthorization"])
},
onShow() {
onShow() {
this.UPDATE_AUTHORIZATIONPAGE(true);
},
onHide() {

View File

@ -289,7 +289,8 @@ export default {
query: { type }
});
},
goGoodsCon(item) {
goGoodsCon(item) {
console.log(item)
this.$yrouter.push({
path: "/pages/shop/GoodsCon/index",
query: { id: item.id }

View File

@ -44,7 +44,7 @@
>拼团</text>
<text class="sign cart-color acea-row row-center-wrapper" v-if="order.seckillId > 0">秒杀</text>
<text class="sign cart-color acea-row row-center-wrapper" v-if="order.bargainId > 0">砍价</text>
<data-format :data="order.addTime"></data-format>
<data-format :date="order.addTime"></data-format>
</view>
<view class="font-color-red">{{ getStatus(order) }}</view>
</view>
@ -209,7 +209,7 @@ export default {
orderList: [],
pay: false,
payType: ["yue", "weixin"],
from: isWeixin() ? "weixin" : "weixinh5"
from: this.$deviceType
};
},
components: {

View File

@ -5,7 +5,7 @@
<view class="data" :class="refundOrder ? 'on' : ''">
<view class="state">{{ orderInfo._status._msg }}</view>
<view>
<data-format :data="orderInfo.addTime"></data-format>
<data-format :date="orderInfo.addTime"></data-format>
</view>
</view>
</view>
@ -144,7 +144,7 @@
<view class="item acea-row row-between">
<view>下单时间</view>
<view class="conter">
<data-format :data="orderInfo.addTime"></data-format>
<data-format :date="orderInfo.addTime"></data-format>
</view>
</view>
<view class="item acea-row row-between">

View File

@ -481,6 +481,26 @@
uni.showLoading({
title: "生成订单中"
});
let form = {}
if (this.$deviceType == 'app') {
form.form = 'app'
}
console.log(this.orderGroupInfo.orderKey, {
realName: this.contacts,
phone: this.contactsTel,
addressId: this.addressInfo.id,
useIntegral: this.useIntegral ? 1 : 0,
couponId: this.usableCoupon.id || 0,
payType: this.active,
pinkId: this.pinkId,
seckillId: this.orderGroupInfo.seckill_id,
combinationId: this.orderGroupInfo.combination_id,
bargainId: this.orderGroupInfo.bargain_id,
from: this.from,
mark: this.mark || "",
shippingType: parseInt(shipping_type) + 1,
...form
})
createOrder(this.orderGroupInfo.orderKey, {
realName: this.contacts,
phone: this.contactsTel,
@ -494,9 +514,11 @@
bargainId: this.orderGroupInfo.bargain_id,
from: this.from,
mark: this.mark || "",
shippingType: parseInt(shipping_type) + 1
shippingType: parseInt(shipping_type) + 1,
...form
})
.then(res => {
.then(res => {
console.log(res)
uni.hideLoading();
const data = res.data;
switch (data.status) {
@ -541,7 +563,8 @@
}, 100);
break;
case "WECHAT_PAY":
weappPay(data.result.jsConfig).then(res => {
weappPay(data.result.jsConfig).then(res => {
console.log(res)
this.$yrouter.replace({
path: "/pages/order/OrderDetails/index",
query: {
@ -569,4 +592,4 @@
}
}
};
</script>
</script>

View File

@ -6,7 +6,7 @@
<view class="order-num">订单{{ orderInfo.orderId }}</view>
<view>
<text class="time">
<data-format :data="orderInfo.addTime"></data-format>
<data-format :date="orderInfo.addTime"></data-format>
</text>
</view>
</view>
@ -67,7 +67,7 @@
<view class="item acea-row row-between">
<view>下单时间</view>
<view class="conter">
<data-format :data="orderInfo.addTime"></data-format>
<data-format :date="orderInfo.addTime"></data-format>
</view>
</view>
<view class="item acea-row row-between">

View File

@ -14,7 +14,7 @@
<text>订单号:{{ item.orderId }}</text>
<text class="time">
<text>下单时间:</text>
<data-format :data="item.addTime"></data-format>
<data-format :date="item.addTime"></data-format>
</text>
</view>
<view class="pos-order-goods" v-for="(val, key) in item.cartInfo" :key="key">

View File

@ -47,7 +47,6 @@
</view>
</template>
<script>
import debounce from "lodash.debounce";
import { getCategory } from "@/api/store";
import { trim } from "@/utils";

File diff suppressed because it is too large Load Diff

View File

@ -79,7 +79,6 @@
<script>
import Recommend from "@/components/Recommend";
import { getProducts } from "@/api/store";
import debounce from "lodash.debounce";
import Loading from "@/components/Loading";
export default {

View File

@ -177,7 +177,6 @@ import {
import { postCollectAll } from "@/api/user";
import { mul, add } from "@/utils/bc";
import cookie from "@/utils/store/cookie";
import debounce from "lodash.debounce";
const CHECKED_IDS = "cart_checked";

View File

@ -84,6 +84,14 @@
<input type="password" placeholder="填写您的登录密码" v-model="password" />
</view>
</view>
<view class="item">
<view>
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" />
</svg> -->
<input type="text" placeholder="输入邀请码" v-model="inviteCode" />
</view>
</view>
</view>
<view class="logon" @click="register">注册</view>
<view class="tip">
@ -112,8 +120,10 @@
} from "@/utils/dialog";
import dayjs from "dayjs";
import cookie from "@/utils/store/cookie";
import {handleGetUserInfo} from '@/utils'
import {
handleGetUserInfo
} from '@/utils'
const BACK_URL = "login_back_url";
@ -126,7 +136,8 @@ import {handleGetUserInfo} from '@/utils'
current: 0,
account: "",
password: "",
captcha: "",
captcha: "",
inviteCode:"",
formItem: 1,
type: "login"
};
@ -211,6 +222,7 @@ import {handleGetUserInfo} from '@/utils'
account: that.account,
captcha: that.captcha,
password: that.password,
inviteCode: that.inviteCode,
spread: cookie.get("spread")
})
.then(res => {
@ -306,11 +318,11 @@ import {handleGetUserInfo} from '@/utils'
.then(({
data
}) => {
this.$store.commit("LOGIN", data.token, dayjs(data.expires_time));
handleGetUserInfo()
// let replace=this.$yroute.query.replace
// if(replace){
this.$store.commit("LOGIN", data.token, dayjs(data.expires_time));
handleGetUserInfo()
// let replace=this.$yroute.query.replace
// if(replace){
// }
// this.$yrouter.replace({
// path: this.$yroute.query.replace || '/pages/home/index'

View File

@ -118,6 +118,14 @@
</view>
<view class="by">
<text class="by-text">By@意象</text>
</view>
<view class="by">
<view>
<text class="by-text">Copyright © 2020</text>
</view>
<view>
<text class="by-text">漯河市大有前途网络科技有限公司</text>
</view>
</view>
<view class="footer-line-height"></view>
<!-- <SwitchWindow
@ -295,7 +303,8 @@
this.MenuUser();
}
},
onShow() {
onShow() {
console.log(this.$store.getters.token)
console.log(this.userInfo);
if (this.$store.getters.token) {
this.User();

View File

@ -14,8 +14,8 @@
<view class="condition line1">购物满{{ item.useMinPrice }}元可用</view>
<view class="data acea-row row-between-wrapper">
<view v-if="item.endTime !== 0">
<data-format-t :data="item.startTime"></data-format-t>-
<data-format-t :data="item.endTime"></data-format-t>
<data-format-t :date="item.startTime"></data-format-t>-
<data-format-t :date="item.endTime"></data-format-t>
</view>
<view v-else>不限时</view>
<view class="bnt gray" v-if="item.isUse === true">已领取</view>

View File

@ -13,7 +13,7 @@
<view class="condition line1">{{ item.couponTitle }}</view>
<view class="data acea-row row-between-wrapper">
<view v-if="item.endTime === 0">不限时</view>
<view v-else><data-format-t :data="item.addTime"></data-format-t> - <data-format-t :data="item.endTime"></data-format-t></view>
<view v-else><data-format-t :date="item.addTime"></data-format-t> - <data-format-t :date="item.endTime"></data-format-t></view>
<view class="bnt gray" v-if="item._type === 0">{{ item._msg }}</view>
<view class="bnt bg-color-red" v-else>{{ item._msg }}</view>
</view>

View File

@ -1,145 +1,153 @@
<template>
<view class="distribution-posters">
<view class="slider-banner banner">
<swiper indicatorDots="true">
<block v-for="(item, infoIndex) in info" :key="infoIndex">
<swiper-item>
<image class="slide-image" :src="item.wap_poster" mode="widthFix" show-menu-by-longpress />
</swiper-item>
</block>
</swiper>
</view>
<view class="keep bg-color-red" @click="saveImg">保存海报</view>
</view>
<view class="distribution-posters">
<view class="slider-banner banner">
<swiper indicatorDots="true">
<block v-for="(item, infoIndex) in info" :key="infoIndex">
<swiper-item>
<image class="slide-image" :src="item.wap_poster" mode="widthFix" show-menu-by-longpress />
</swiper-item>
</block>
</swiper>
</view>
<view class="keep bg-color-red" @click="saveImg">保存海报</view>
</view>
</template>
<script>
// import { swiper, swiperSlide } from "vue-awesome-swiper";
import { getSpreadImg } from "@/api/user";
// import { swiper, swiperSlide } from "vue-awesome-swiper";
import {
getSpreadImg
} from "@/api/user";
export default {
name: "Poster",
components: {
// swiper,
// swiperSlide
},
props: {},
data: function() {
return {
swiperPosters: {
speed: 1000,
effect: "coverflow",
slidesPerView: "auto",
centeredSlides: true,
coverflowEffect: {
rotate: 0, // 旋转的角度
stretch: -20, // 拉伸 图片间左右的间距和密集度
depth: 100, // 深度 切换图片间上下的间距和密集度
modifier: 3, // 修正值 该值越大前面的效果越明显
slideShadows: false // 页面阴影效果
},
observer: true,
observeParents: true
},
info: [],
activeIndex: 0
};
},
mounted: function() {
this.getIndex();
let that = this;
// this.swiper.on("slideChange", function() {
// that.activeIndex = that.swiper.activeIndex;
// });
},
computed: {
swiper() {
// return this.$refs.mySwiper.swiper;
}
},
methods: {
getIndex: function() {
let that = this;
getSpreadImg().then(
res => {
that.info = res.data;
},
err => {
uni.showToast({
title: err.msg || err.response.data.msg,
icon: 'none',
duration: 2000
});
}
);
},
downloadIamge: function(imgsrc, name) {
var that = this;
this.isDown = true;
var downloadUrl = imgsrc;
export default {
name: "Poster",
components: {
// swiper,
// swiperSlide
},
props: {},
data: function() {
return {
swiperPosters: {
speed: 1000,
effect: "coverflow",
slidesPerView: "auto",
centeredSlides: true,
coverflowEffect: {
rotate: 0, // 旋转的角度
stretch: -20, // 拉伸 图片间左右的间距和密集度
depth: 100, // 深度 切换图片间上下的间距和密集度
modifier: 3, // 修正值 该值越大前面的效果越明显
slideShadows: false // 页面阴影效果
},
observer: true,
observeParents: true
},
info: [],
activeIndex: 0
};
},
mounted: function() {
this.getIndex();
let that = this;
// this.swiper.on("slideChange", function() {
// that.activeIndex = that.swiper.activeIndex;
// });
},
computed: {
swiper() {
// return this.$refs.mySwiper.swiper;
}
},
methods: {
getIndex: function() {
let that = this;
let form = {}
if (this.$deviceType == 'app') {
form.form = 'app'
}
getSpreadImg(form).then(
res => {
that.info = res.data;
},
err => {
uni.showToast({
title: err.msg || err.response.data.msg,
icon: 'none',
duration: 2000
});
}
);
},
downloadIamge: function(imgsrc, name) {
var that = this;
this.isDown = true;
var downloadUrl = imgsrc;
if (!wx.saveImageToPhotosAlbum) {
uni.showModal({
title: "提示",
content:
"当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。"
});
that.openDialogVisible = true;
if (!wx.saveImageToPhotosAlbum) {
uni.showModal({
title: "提示",
content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。"
});
that.openDialogVisible = true;
return;
}
return;
}
// 可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.writePhotosAlbum" 这个 scope
wx.getSetting({
success(res) {
if (!res.authSetting["scope.writePhotosAlbum"]) {
that.openDialogVisible = true;
// 可以通过 wx.getSetting 先查询一下用户是否授权了 "scope.writePhotosAlbum" 这个 scope
wx.getSetting({
success(res) {
if (!res.authSetting["scope.writePhotosAlbum"]) {
that.openDialogVisible = true;
// 接口调用询问
wx.authorize({
scope: "scope.writePhotosAlbum",
success() {
that.downloadImage(downloadUrl);
},
fail() {
// 用户拒绝了授权
// 打开设置页面
wx.openSetting({
success: function(data) {},
fail: function(data) {}
});
}
});
} else {
that.downloadImage(downloadUrl);
}
},
fail(res) {
that.openDialogVisible = true;
}
});
},
saveImg: function() {
this.downloadIamge(
this.info[this.activeIndex].wap_poster,
"poster" + this.activeIndex
);
}
}
};
// 接口调用询问
wx.authorize({
scope: "scope.writePhotosAlbum",
success() {
that.downloadImage(downloadUrl);
},
fail() {
// 用户拒绝了授权
// 打开设置页面
wx.openSetting({
success: function(data) {},
fail: function(data) {}
});
}
});
} else {
that.downloadImage(downloadUrl);
}
},
fail(res) {
that.openDialogVisible = true;
}
});
},
saveImg: function() {
this.downloadIamge(
this.info[this.activeIndex].wap_poster,
"poster" + this.activeIndex
);
}
}
};
</script>
<style scoped lang="less">
.distribution-posters {
height: 100%;
}
.banenr {
height: 100%;
}
.banner swiper {
height: 100%;
}
.banner .slide-image {
width: 100%;
height: auto;
}
</style>
.distribution-posters {
height: 100%;
}
.banenr {
height: 100%;
}
.banner swiper {
height: 100%;
}
.banner .slide-image {
width: 100%;
height: auto;
}
</style>

View File

@ -45,7 +45,7 @@
<view>
<view class="state">{{ item.title }}</view>
<view>
<data-format :data="item.addTime"></data-format>
<data-format :date="item.addTime"></data-format>
</view>
</view>
<view class="num" v-if="item.pm == 1">+{{ item.number }}</view>