外卖CPS红包小程序源码分享
外卖cps带分销返利源码
饿了么红包、美团优惠券开发(外卖cps,三级裂变源码)
源代码地址
搭建步骤
- 下载以上源代码到本地
http://y.mybei.cn
截图
步骤
- 下载以上源代码到本地
http://www.mybei.cn - 修改为你自己的微信小程序,打开 /dist/pages/ele/index.js
- 微信小程序->开发管理->开发设置 添加 request的域名: 地址:
https://mp.weixin.qq.com/wxamp/devprofile/get_profile?token=271531762&lang=zh_CN
- 小程序管理后台配置你的链接
后台地址: http://q.mybei.cn - 进去之后选择小程序管理->无裂变小程序管理->添加小程序->填入你自己的链接
- 微信开发者工具,导入项目,提交审核
const Base = require(’./base.js’);
const moment = require(‘moment’);
const fs = require(‘fs’);
const path = require(“path”);
const qiniu = require(‘qiniu’);
module.exports = class extends Base {
/**
* index action
* @return {Promise} []
*/
async indexAction() {
const page = this.get(‘page’) || 1;
const size = this.get(‘size’);
const name = this.get(‘name’) || ‘’;
const model = this.model(‘goods’);
const data = await model.where({
name: [‘like’, %${name}%
],
is_delete: 0
}).order([‘sort_order asc’]).page(page, size).countSelect();
// let newData = data;
for (const item of data.data) {
const info = await this.model(‘category’).where({
id: item.category_id
}).find();
item.category_name = info.name;
if (item.is_on_sale == 1) {
item.is_on_sale = true;
} else {
item.is_on_sale = false;
}
if (item.is_index == 1) {
item.is_index = true;
} else {
item.is_index = false;
}
let product = await this.model(‘product’).where({
goods_id: item.id,
is_delete: 0
}).select();
for (const ele of product) {
let spec = await this.model(‘goods_specification’).where({
id: ele.goods_specification_ids,
is_delete: 0
}).find();
ele.value = spec.value;
ele.is_on_sale = ele.is_on_sale ? “1” : “0”;
}
item.product = product;
}
return this.success(data);
}
async getExpressDataAction() {
let kd = [];
let cate = [];
const kdData = await this.model(‘freight_template’).where({
is_delete: 0
}).select();
for (const item of kdData) {
kd.push({
value: item.id,
label: item.name
})
}
const cateData = await this.model(‘category’).where({
parent_id: 0
}).select();
for (const item of cateData) {
cate.push({
value: item.id,
label: item.name
})
}
let infoData = {
kd: kd,
cate: cate
};
return this.success(infoData);
}
async copygoodsAction() {
const goodsId = this.post(‘id’);
let data = await this.model(‘goods’).where({
id: goodsId
}).find();
delete data.id;
data.is_on_sale = 0;
let insertId = await this.model(‘goods’).add(data);
let goodsGallery = await this.model(‘goods_gallery’).where({
goods_id: goodsId,
is_delete:0,
}).select();
for (const item of goodsGallery) {
let gallery = {
img_url: item.img_url,
sort_order: item.sort_order,
goods_id: insertId
}
await this.model(‘goods_gallery’).add(gallery);
}
return this.success(insertId);
}
async updateStock(goods_sn, goods_number) {
think.logger.info(‘存在,现在就更新’);
await this.model(‘product’).where({
goods_sn: goods_sn
}).update({
goods_number: goods_number
});
}
async updateGoodsNumberAction() {
let all_goods = await this.model(‘goods’).where({
is_delete: 0,
is_on_sale: 1
}).select();
for (const item of all_goods) {
let goodsSum = await this.model(‘product’).where({
goods_id: item.id
}).sum(‘goods_number’);
await this.model(‘goods’).where({
id: item.id
}).update({
goods_number: goodsSum
});
await think.timeout(2000);
}
return this.success();
}
async onsaleAction() {
const page = this.get(‘page’) || 1;
const size = this.get(‘size’);
const model = this.model(‘goods’);
const data = await model.where({
is_delete: 0,
is_on_sale: 1
}).order([‘sort_order asc’]).page(page, size).countSelect();
for (const item of data.data) {
const info = await this.model(‘category’).where({
id: item.category_id
}).find();
item.category_name = info.name;
// if (info.parent_id != 0) {
// const parentInfo = aw