Authored by 黄敬囿

Merge branch 'promotion1.0' into 'master'

Promotion1.0

merge

See merge request !18
{
"component": true,
"usingComponents": {
"dialog": "../../components/dialog/dialog"
"dialog": "../../components/tip-dialog/index"
}
}
... ...
... ... @@ -7,39 +7,46 @@ Component({
},
coupons: {
type: Array,
value: []
value: [],
},
selectedCode: {
type: String,
value: '',
},
chosenIdx: {
type: String,
value: ''
}
},
},
data: {
chosenIdx: ''
// chosenIdx: ''
},
methods: {
confirm: function () {
let item = this.data.coupons[this.data.chosenIdx];
let codeType = item && item.coupon_type|| '';
let code = item && item.coupon_code || '';
let amount = item && item.coupon_value_str || '';
this.triggerEvent('confirmselect', {code, amount})
this.triggerEvent('confirmselect', { code, amount, codeType})
},
cancel: function () {
this.triggerEvent('cancel')
},
check: function (e) {
let idx = e.currentTarget.dataset.idx;
let that = this;
this.data.coupons.forEach((item, index) => {
let listItem = item;
if (index !== idx && item.isChosen) {
this.setData({
[`coupons[${index}].isChosen`]: false
[`coupons[${index}].isChosen`]: false,
[`coupons[${idx}].selected`]: 'N'
});
}
if (index === idx) {
this.setData({
[`coupons[${idx}].isChosen`]: true
[`coupons[${idx}].isChosen`]: true,
[`coupons[${idx}].selected`]: 'Y'
});
}
});
... ... @@ -49,7 +56,8 @@ Component({
let idx = e.currentTarget.dataset.idx;
this.setData({
[`coupons[${idx}].isChosen`]: false
[`coupons[${idx}].isChosen`]: false,
[`coupons[${idx}].selected`]: 'N'
});
this.data.chosenIdx = '';
},
... ... @@ -77,6 +85,7 @@ Component({
this.data.chosenIdx = '';
}
}
console.log(this.data.coupons)
}
}
});
... ...
// src/components/dialog/dialog.js
Component({
options: {
multipleSlots: true // 在组件定义时的选项中启用多slot支持
},
/**
* 组件的属性列表
* 用于组件自定义设置
*/
properties: {
// 弹窗标题
title: { // 属性名
type: String, // 类型(必填),目前接受的类型包括:String, Number, Boolean, Object, Array, null(表示任意类型)
value: '标题' // 属性初始值(可选),如果未指定则会根据类型选择一个
},
// 弹窗内容
content: {
type: String,
value: '弹窗内容'
},
// 弹窗取消按钮文字
cancelText: {
type: String,
value: '取消'
},
// 弹窗确认按钮文字
confirmText: {
type: String,
value: '确定'
}
},
/**
* 私有数据,组件的初始数据
* 可用于模版渲染
*/
data: {
// 弹窗显示控制
isShow: false
},
/**
* 组件的方法列表
* 更新属性和数据的方法与更新页面数据的方法类似
*/
methods: {
/*
* 公有方法
*/
_showChange(isShow) {
console.log("===isShow==" + isShow)
this.setData({ isShowLeft: isShow })
},
//隐藏弹框
hideDialog() {
this.setData({
isShow: !this.data.isShow
})
},
//展示弹框
showDialog() {
this.setData({
isShow: !this.data.isShow
})
},
/*
* 内部私有方法建议以下划线开头
* triggerEvent 用于触发事件
*/
_cancelEvent() {
this.triggerEvent("cancelEvent")
},
_confirmEvent() {
this.triggerEvent("confirmEvent");
}
}
})
... ...
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--src/components/tip-dialog/index.wxml-->
<!--src/components/dialog/dialog.wxml-->
<view class='wx_dialog_container' hidden="{{!isShow}}">
<view class='wx-mask'></view>
<view class='wx-dialog'>
<view class='wx-dialog-content'>{{ content }}</view>
<view class='wx-dialog-footer'>
<view class='wx-dialog-btn' bindtap="_confirmEvent">{{ confirmText }}</view>
</view>
</view>
</view>
... ...
/* src/components/tip-dialog/index.wxss */
/* src/components/dialog/dialog.wxss */
.wx-mask{
position: fixed;
z-index: 1000;
top: 0;
right: 0;
left: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.3);
}
.wx-dialog{
position: fixed;
z-index: 5000;
width: 560rpx;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
background-color: #FFFFFF;
text-align: center;
border-radius: 3rpx;
overflow: hidden;
}
.wx-dialog-title{
font-size: 30rpx;
padding: 15rpx 15rpx 5rpx;
}
.wx-dialog-content{
height: 240rpx;
font-size: 30rpx;
display:flex;
align-items:center;/*垂直居中*/
justify-content: center;/*水平居中*/
margin: 0 50rpx;
}
.wx-dialog-footer{
display: flex;
align-items: center;
position: relative;
height: 100rpx;
font-size: 30rpx;
}
.wx-dialog-footer::before{
content: '';
position: absolute;
left: 0;
top: 0;
right: 0;
height: 1px;
border-top: 1rpx solid #D5D5D6;
color: #D5D5D6;
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
}
.wx-dialog-btn{
display: block;
-webkit-flex: 1;
flex: 1;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
position: relative;
height:100%;
line-height:100rpx;
}
.wx-dialog-footer .wx-dialog-btn:nth-of-type(1){
color: #000;
}
.wx-dialog-footer .wx-dialog-btn:nth-of-type(2){
color: #000;
}
.wx-dialog-footer .wx-dialog-btn:nth-of-type(2):after{
content: " ";
position: absolute;
left: 0;
top: 0;
width: 1rpx;
bottom: 0;
border-left: 2rpx solid #D5D5D6;
color: #D5D5D6;
-webkit-transform-origin: 0 0;
transform-origin: 0 0;
-webkit-transform: scaleX(0.5);
transform: scaleX(0.5);
}
... ...
const app_version = '1.0.0'
const app_version = '1.1.5'
const build_code = 1000
const private_key = 'b43890b0a296ff3c7b8c260ca763980b'
const appid = 'wxc677c88385762287'
export default {
... ... @@ -19,6 +20,14 @@ export default {
// activityHost: 'https://action.yoho.cn',
// reportHost: 'https://app.yoho.cn/collect/v3',
// yasHost: 'https://analysis.yohobuy.com/yas_mobile'
// grey
// api: 'http://2.yohobuy.com',
// yohoApi: 'http://54.223.33.55',
// yohoLogin: 'http://54.223.33.55',
// activityHost: 'https://action.yoho.cn',
// reportHost: 'https://app.yoho.cn/collect/v3',
// yasHost: 'https://analysis.yohobuy.com/yas_mobile'
},
apiParams: {
client_type: 'miniapp',
... ... @@ -53,6 +62,7 @@ export default {
source_type: 'wechat',
user_source: 'wechat',
business_line: 'miniappUFO',
build_code: build_code,
},
unionType: '', // 渠道号
// MINI_APP_DOMAIN: 'miniapp.yohobuy.com',
... ...
... ... @@ -15,7 +15,8 @@ export default {
url: '/shopping',
data: {
method: CREATE_PAYMENTINFO,
skup
skup,
api_version: '1'
}
})
},
... ...
... ... @@ -148,7 +148,7 @@ export default class Index extends Component {
commonModel.search({
limit: 10,
type: type,
page: page[type]
page: page[type] || 1
}).then(ret => {
if (ret && ret.code === 200) {
let list = ret.data && ret.data.product_list || [];
... ...
... ... @@ -33,6 +33,7 @@ Page({
selectCouponCode: '',
selectCouponAmount: '',
selectingCoupon: false,
promotionid: '',
user_activity_id: '' // 有值代表砍价
},
onLoad: async function (option) {
... ... @@ -56,10 +57,14 @@ Page({
return;
}
//选中优惠卷后,切到后台,再切回前台页面,不在请求数据
if (!this.data.selectCouponCode) {
await this.fetchData(this.data.isStore);
if (!this.data.isStore) {
if (!this.data.isStore && !this.data.hasAddress) {
await this.fetchAddress()
}
}
},
showSelectCoupon: function () {
... ... @@ -69,27 +74,53 @@ Page({
},
async confirmSelectCoupon({detail}) {
let code = detail.code;
let codeType = detail.codeType;
let amount = detail.amount || '';
let couponsList = this.data.couponList;
if (couponsList){
couponsList.forEach((item, index) => {
if (code === item.coupon_code) {
item.isChosen = true;
item.selected = 'Y'
}
});
}
this.setData({
couponsList,
selectCouponAmount: amount,
selectCouponCode: code,
selectingCoupon: false
selectingCoupon: false,
selectingCouponType: codeType
});
// 区分线上线下
let info;
//如果选择了非运费券,促销不选择
let promotion_id = '';
if (this.data && this.data.promotionTips && this.data.promotionTips.promotionIds) {
promotion_id = this.data.promotionTips.promotionIds;
}
//判断优惠劵的类型
if (code && codeType !== 110){
promotion_id = '';
}
try {
if (this.data.isStore) {
info = await api.orderOfflineCompute({
skup: this.data.skup,
coupon_code: code
coupon_code: code,
promotionId: promotion_id,
app_version: '1'
}, () => wx.hideLoading());
} else {
const params = {
skup: this.data.skup,
coupon_code: code
coupon_code: code,
promotionid: promotion_id
};
if (this.data.user_activity_id) {
... ... @@ -121,7 +152,8 @@ Page({
});
let params = {
skup: this.data.skup,
store_id: this.data.storeId
store_id: this.data.storeId,
api_version: '1'
}
if (this.data.user_activity_id) {
... ... @@ -155,10 +187,23 @@ Page({
}
}
api.orderSelectCoupon(this.data.skup, () => wx.hideLoading()).then(data => {
let coupons = data || [];
this.setData(coupons)
// await api.orderSelectCoupon(this.data.skup, () => wx.hideLoading()).then(data => {
// this.setData(coupons)
// });
let that = this;
if (data && data.couponList && data.couponList.length > 0){
let coupons = [];
data.couponList.forEach((item, index) => {
let selected = item.selected;
if (selected === 'Y'){
item.isChosen = true;
data.selectCouponAmount = item.coupon_value_str;
data.selectCouponCode = item.coupon_code;
}else {
item.isChosen = false;
}
});
}
if (data.good && data.good.goodImg) {
data.good.goodImg = getImgUrl(data.good.goodImg, 270, 270)
... ... @@ -202,18 +247,26 @@ Page({
},
async submit() {
if (!this.data.agreeProtocol) return;
let data;
try {
let promotionId = '';
if (this.data && this.data.promotionTips && this.data.promotionTips.promotionIds){
promotionId = this.data.promotionTips.promotionIds;
}
if (this.data.selectingCouponType && this.data.selectingCouponType !== 110) {
promotionId = '';
}
if (this.data.isStore) {
this.check = this.selectComponent("#check");
let checkRes = await this.check.init();
if (!checkRes.result) return;
let param = checkRes.data;
param.skup = this.data.skup
param.skup = this.data.skup;
param.api_version = '1';
param.coupon_code = this.data.selectCouponCode || '';
param.promotionId = promotionId;
// wx.showLoading({
// title: '',
// })
... ... @@ -235,6 +288,7 @@ Page({
let couponCode = this.data.selectCouponCode || '';
let extra = null;
if (this.data.user_activity_id) {
extra = {
user_activity_id: this.data.user_activity_id,
... ... @@ -245,7 +299,7 @@ Page({
// wx.showLoading({
// title: '',
// })
data = await api.buyerSubmit({skup, channelNo, addressId, couponCode, extra}, () => wx.hideLoading());
data = await api.buyerSubmit({ skup, channelNo, addressId, couponCode, promotionId, extra}, () => wx.hideLoading());
}
if (data && data.orderCode) {
let skup = this.data.skup
... ...
... ... @@ -8,6 +8,7 @@
<productCell productInfo="{{good}}" isStore="{{isStore === 1}}"></productCell>
<!-- // 砍价没有优惠券 -->
<couponCell wx:if="{{!user_activity_id}}" bindselect="showSelectCoupon" amount="{{selectCouponAmount}}"></couponCell>
<priceCell promotionFormulaList="{{promotionFormulaList}}" damagesDesc="{{damagesDesc}}" isStore="{{isStore === 1}}"></priceCell>
<payDeliveryCell paymentWay="{{paymentWay}}" deliveryWay="{{deliveryWay}}"></payDeliveryCell>
</scroll-view>
... ... @@ -38,5 +39,5 @@
</view>
</view>
<couponSelect bindconfirmselect="confirmSelectCoupon" show="{{selectingCoupon}}" selected-code="{{selectCouponCode}}"
bindcancel="cancelSelectCoupon" coupons="{{coupons}}"></couponSelect>
bindcancel="cancelSelectCoupon" coupons="{{couponList}}" chosenIdx="{{chosenIdx}}"></couponSelect>
<checkstore id="check" storeId="{{storeId}}" productId="{{product_id}}"></checkstore>
... ...
... ... @@ -56,14 +56,17 @@ export default class orderService extends BaseService {
})
}
async buyerSubmit({skup, channelNo = '2919', addressId, couponCode, complete, extra = {}} ) {
async buyerSubmit({ skup, channelNo = '2919', addressId, couponCode, complete, promotionId, extra = {}} ) {
return await this.GET(Object.assign({
method: BUYER_SUBMIT,
skup,
channelNo,
addressId,
coupon_code: couponCode || ''
promotionId,
coupon_code: couponCode || '',
app_version: '1'
}, extra), {
path: '/shopping',
complete
... ...
... ... @@ -108,7 +108,8 @@ export default class ProductDetail extends Component {
if (options && options.q) {
let url = decodeURIComponent(options.q);
let urlObj = urlParse.parse(url);
if (urlObj.host === 'o.yohobuy.com' && urlObj.pathname === '/ufo') {
// console
if (urlObj.host === '2.yohobuy.com' && urlObj.pathname === '/ufo') {
const queryObj = queryString.parse(urlObj.query);
const p = queryObj.p;
const storeArr = p.split(',') || [];
... ... @@ -656,7 +657,7 @@ export default class ProductDetail extends Component {
</Button>)
}
{
(!isGoApp && skup) && <Image className="goYohoBuy" onClick={this.goOnLineProuduct.bind(this, id)} src={goOnLine} mode="aspectFill" />
// (!isGoApp && skup) && <Image className="goYohoBuy" onClick={this.goOnLineProuduct.bind(this, id)} src={goOnLine} mode="aspectFill" />
}
{
(!isGoApp && !skup) && <Image className="goYohoBuy" onClick={this.goYohoBuyMinApp.bind(this)} src={goYohoBuy} mode="aspectFill" />
... ...
... ... @@ -6,7 +6,8 @@ import Taro from '@tarojs/taro'
const ACTION_TYPE = {
h5: 'go.h5',
ufo: 'go.ufo'
ufo: 'go.ufo',
productDetail: 'go.ufoProductDetail',
}
const OPEN_BY_TYPE = {
... ... @@ -56,6 +57,10 @@ export default {
this.handleUFOJumpPage(yoho);
break;
}
case ACTION_TYPE.productDetail: {
this.handleUFOJumpPage(yoho);
break;
}
}
},
handleUFOJumpPage(yoho) {
... ...