123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: () => {
- const { reactive, onMounted, getCurrentInstance } = Vue
- const index = {
- setup() {
- const { proxy } = getCurrentInstance();
- const state = reactive({
- data: [],
- tabActive: null,
- configis_upgrade: false,
- })
- const type = reactive({
- data: {
- api: Config.configList.filter((item) => {
- if (item.status) return item;
- })
- }
- })
- const form = reactive({
- model: {},
- rules: {
- rechargewithdraw: {
- recharge: {
- quick_amounts: {
- money: [{ required: true, message: '请输入金额', trigger: 'blur' }],
- gift: [{ required: true, message: '请输入内容', trigger: 'blur' }],
- }
- }
- },
- commission: {
- agent_form: {
- background_image: [{ required: true, message: '请选择表单背景图', trigger: 'blur' }],
- content: {
- type: [{ required: true, message: '表单类型', trigger: 'change' }],
- name: [{ required: true, message: '表单名称', trigger: 'blur' }],
- },
- },
- }
- },
- })
- function getData() {
- if (!state.tabActive) return;
- if (state.tabActive == 'shopro/config/platform') {
- getPlatformStatus()
- } else if (state.tabActive == 'shopro/pay_config') {
- getPayConfig()
- } else {
- Fast.api.ajax({
- url: state.tabActive,
- type: 'GET',
- }, function (ret, res) {
- form.model = res.data;
- // 用户配置
- if (state.tabActive == 'shopro/config/user') {
- getGroupSelect()
- }
- if (state.tabActive == 'shopro/config/dispatch') {
- form.model.sender.area_arr = []
- form.model.sender.area_arr.push(form.model.sender.province_name)
- form.model.sender.area_arr.push(form.model.sender.city_name)
- form.model.sender.area_arr.push(form.model.sender.district_name)
- express.form.model = form.model.kdniao.express
- getExpressSelect()
- getAreaSelect()
- }
- if (state.tabActive == 'shopro/config/commission') {
- if (form.model.become_agent.type == 'goods') {
- getGoodsList(form.model.become_agent.value);
- }
- if (!Config.is_pro) {
- state.configis_upgrade = true
- }
- }
- if (state.tabActive == 'shopro/config/chat') {
- getChatConfig()
- }
- return false
- }, function (ret, res) { })
- }
- }
- // 基础配置
- function onSelectRichtext(type) {
- Fast.api.open(`shopro/data/richtext/select`, '选择富文本', {
- callback(data) {
- form.model[type].id = data.id;
- form.model[type].title = data.title;
- }
- })
- }
- // 用户配置
- const group = reactive({
- select: []
- })
- function getGroupSelect() {
- Fast.api.ajax({
- url: 'shopro/user/group/select',
- type: 'GET',
- }, function (ret, res) {
- group.select = res.data
- return false
- }, function (ret, res) { })
- }
- // 平台配置
- const platform = reactive({
- data: [{
- value: 'H5',
- label: 'H5',
- color: '#fc800e',
- },
- {
- value: 'WechatOfficialAccount',
- label: '微信公众号',
- color: '#07c160',
- },
- {
- value: 'WechatMiniProgram',
- label: '微信小程序',
- color: '#6f74e9',
- },
- {
- value: 'App',
- label: 'App',
- color: '#806af6',
- }],
- status: {},
- })
- function getPlatformStatus() {
- Fast.api.ajax({
- url: 'shopro/config/platformStatus',
- type: 'GET',
- }, function (ret, res) {
- platform.status = res.data
- return false
- }, function (ret, res) { })
- }
- function onEditPlatform(item) {
- Fast.api.open(`shopro/config/platform/platform/${item.value}?platform=${item.value}&label=${item.label}`, `平台-${item.label}`, {
- callback() {
- getData()
- }
- })
- }
- // 物流配置
- const area = reactive({
- select: []
- })
- function getAreaSelect() {
- Fast.api.ajax({
- url: 'shopro/data/area/select',
- type: 'GET',
- }, function (ret, res) {
- area.select = res.data;
- return false
- }, function (ret, res) { })
- }
- const express = reactive({
- form: {
- model: {}
- },
- })
- const deliverCompany = reactive({
- loading: false,
- select: [],
- pagination: {
- page: 1,
- list_rows: 10,
- total: 0,
- }
- })
- function getExpressSelect(keyword) {
- let search = {};
- if (keyword) {
- search = { keyword: keyword };
- }
- Fast.api.ajax({
- url: 'shopro/data/express',
- type: 'GET',
- data: {
- page: deliverCompany.pagination.page,
- list_rows: deliverCompany.pagination.list_rows,
- search: JSON.stringify(search),
- }
- }, function (ret, res) {
- deliverCompany.select = res.data.data
- deliverCompany.pagination.total = res.data.total
- return false
- }, function (ret, res) { })
- }
- function onChangeExpressCode(code) {
- express.form.model = {}
- express.form.model.code = code
- express.form.model.name = proxy.$refs[`express-${code}`][0].label;
- }
- function remoteMethod(keyword) {
- deliverCompany.loading = true;
- setTimeout(() => {
- deliverCompany.loading = false;
- getExpressSelect(keyword);
- }, 200);
- }
- function onThinkApi() {
- window.open('https://docs.topthink.com/think-api/1835396');
- }
- // 充值提现
- function onAddTemplate() {
- form.model.recharge.quick_amounts.push({
- money: '',
- gift: '',
- });
- }
- function onDeleteTemplate(index) {
- form.model.recharge.quick_amounts.splice(index, 1);
- }
- // 分销配置
- function onChangeBecomeAgentType(type) {
- if (type === 'user') {
- form.model.invite_lock = 'share';
- }
- if (type === 'apply') {
- form.model.agent_form.status = '1';
- }
- if (type === 'goods') {
- tempGoods.list = [];
- }
- form.model.become_agent.value = '';
- }
- const tempGoods = reactive({
- list: [],
- });
- async function getGoodsList(ids) {
- Fast.api.ajax({
- url: 'shopro/goods/goods/select',
- type: 'GET',
- data: {
- type: 'select',
- search: JSON.stringify({ id: [ids, 'in'] }),
- },
- }, function (ret, res) {
- tempGoods.list = res.data;
- return false
- }, function (ret, res) { })
- }
- function onSelectGoods() {
- let ids = [];
- tempGoods.list.forEach((i) => {
- ids.push(i.id);
- });
- Fast.api.open(`shopro/goods/goods/select?multiple=true&ids=${ids.join(',')}`, "选择商品", {
- callback(data) {
- tempGoods.list = data;
- let ids = [];
- tempGoods.list.forEach((item) => {
- ids.push(item.id);
- });
- form.model.become_agent.value = ids.join(',');
- }
- })
- }
- function onDeleteGoods(index) {
- tempGoods.list.splice(index, 1);
- let ids = [];
- tempGoods.list.forEach((gl) => {
- ids.push(gl.id);
- });
- form.model.become_agent.value = ids.join(',');
- }
- const become_register_options = [
- {
- value: 'text',
- label: '文本内容',
- },
- {
- value: 'number',
- label: '纯数字',
- },
- {
- value: 'image',
- label: '上传图片',
- },
- ];
- function onAddContent() {
- form.model.agent_form.content.push({
- type: '',
- name: '',
- });
- }
- function onDeleteContent(index) {
- form.model.agent_form.content.splice(index, 1);
- }
- // 支付配置
- const payConfig = reactive({
- data: []
- })
- function getPayConfig() {
- Fast.api.ajax({
- url: 'shopro/pay_config',
- type: 'GET',
- }, function (ret, res) {
- payConfig.data = res.data.data
- pagination.total = res.data.total
- return false
- }, function (ret, res) { })
- }
- const pagination = reactive({
- page: 1,
- list_rows: 10,
- total: 0,
- })
- function onCommandPayConfig(item) {
- Fast.api.ajax({
- url: `shopro/pay_config/edit/id/${item.id}`,
- type: 'POST',
- data: {
- status: item.type
- }
- }, function (ret, res) {
- getPayConfig()
- }, function (ret, res) { })
- }
- function onAddPayConfig() {
- Fast.api.open('shopro/pay_config/add?type=add', "添加", {
- callback() {
- getPayConfig()
- }
- })
- }
- function onEditPayConfig(id) {
- Fast.api.open(`shopro/pay_config/edit?type=edit&id=${id}`, "编辑", {
- callback() {
- getPayConfig()
- }
- })
- }
- function onDeletePayConfig(id) {
- Fast.api.ajax({
- url: `shopro/pay_config/delete/id/${id}`,
- type: 'DELETE',
- }, function (ret, res) {
- getPayConfig()
- }, function (ret, res) { })
- }
- function onRecyclebinPayConfig() {
- Fast.api.open(`shopro/pay_config/recyclebin`, "回收站", {
- callback() {
- getPayConfig()
- }
- })
- }
- // 客服配置
- const chat = reactive({
- config: {}
- })
- function getChatConfig() {
- Fast.api.ajax({
- url: `shopro/chat/index/init`,
- type: 'GET',
- }, function (ret, res) {
- chat.config = res.data
- return false
- }, function (ret, res) { })
- }
- function onConfirm() {
- const submitForm = JSON.parse(JSON.stringify(form.model))
- if (state.tabActive == 'shopro/config/dispatch') {
- if (submitForm.sender.area_arr) {
- submitForm.sender.province_name = submitForm.sender.area_arr[0]
- submitForm.sender.city_name = submitForm.sender.area_arr[1]
- submitForm.sender.district_name = submitForm.sender.area_arr[2]
- delete submitForm.sender.area_arr
- } else {
- submitForm.sender.province_name = ''
- submitForm.sender.city_name = ''
- submitForm.sender.district_name = ''
- }
- submitForm.kdniao.express = express.form.model
- }
- if (state.tabActive == 'shopro/config/redis') {
- if (submitForm.empty_password) {
- delete submitForm.password
- }
- }
- proxy.$refs['formRef'].validate((valid) => {
- if (valid) {
- Fast.api.ajax({
- url: state.tabActive,
- type: 'POST',
- data: submitForm,
- }, function (ret, res) {
- }, function (ret, res) { })
- }
- });
- }
- function onOper(type) {
- switch (type) {
- case 'close':
- state.configis_upgrade = false
- break;
- case 'refresh':
- window.location.reload();
- break;
- case 'upgrade':
- window.open("https://www.fastadmin.net/store/shopro.html")
- break;
- }
- }
- onMounted(() => {
- state.tabActive = type.data.api.length ? type.data.api[0].name : null;
- getData()
- })
- return {
- onClipboard,
- state,
- type,
- form,
- getData,
- onSelectRichtext,
- group,
- platform,
- onEditPlatform,
- area,
- express,
- deliverCompany,
- getExpressSelect,
- onChangeExpressCode,
- remoteMethod,
- onThinkApi,
- onAddTemplate,
- onDeleteTemplate,
- onChangeBecomeAgentType,
- tempGoods,
- onSelectGoods,
- onDeleteGoods,
- become_register_options,
- onAddContent,
- onDeleteContent,
- payConfig,
- pagination,
- onCommandPayConfig,
- onAddPayConfig,
- onEditPayConfig,
- onDeletePayConfig,
- onRecyclebinPayConfig,
- chat,
- onConfirm,
- onOper
- }
- }
- }
- createApp('index', index);
- },
- platform: () => {
- const { reactive, onMounted, getCurrentInstance } = Vue
- const platform = {
- setup() {
- const { proxy } = getCurrentInstance();
- const state = reactive({
- platform: new URLSearchParams(location.search).get('platform'),
- label: new URLSearchParams(location.search).get('label'),
- })
- const form = reactive({
- model: {
- app_id: '',
- secret: '',
- status: '',
- payment: {
- alipay: '',
- wechat: '',
- methods: [],
- },
- share: {
- methods: [],
- forwardInfo: {
- title: '',
- subtitle: '',
- image: '',
- },
- linkAddress: '',
- posterInfo: {
- user_bg: '',
- goods_bg: '',
- groupon_bg: '',
- },
- },
- download: {
- android: '',
- ios: '',
- local: '',
- },
- },
- rules: {}
- })
- function getDetail() {
- Fast.api.ajax({
- url: `shopro/config/platform/platform/${state.platform}`,
- type: 'GET',
- }, function (ret, res) {
- form.model = res.data;
- if (isEmpty(form.model.share)) {
- form.model.share = {
- methods: [],
- forwardInfo: {
- title: '',
- subtitle: '',
- image: '',
- },
- linkAddress: '',
- posterInfo: {
- user_bg: '',
- goods_bg: '',
- groupon_bg: '',
- },
- };
- }
- if (isEmpty(form.model.download)) {
- form.model.download = {
- android: '',
- ios: '',
- local: '',
- };
- }
- if (state.platform != 'H5' && !form.model.share.methods.includes('forward')) {
- form.model.share.methods.push('forward');
- }
- if (form.model.payment.wechat === 0) {
- form.model.payment.wechat = ''
- }
- if (form.model.payment.alipay === 0) {
- form.model.payment.alipay = ''
- }
- return false
- }, function (ret, res) { })
- }
- function onConfiguration() {
- if (state.platform == 'H5') {
- window.open('https://pay.weixin.qq.com/wiki/doc/apiv3/open/pay/chapter2_6_1.shtml');
- }
- if (state.platform == 'App') {
- window.open('https://open.weixin.qq.com/');
- }
- }
- const payConfig = reactive({
- select: {
- alipay: [],
- wechat: [],
- }
- })
- function getPayConfigSelect() {
- Fast.api.ajax({
- url: 'shopro/pay_config/select',
- type: 'GET',
- }, function (ret, res) {
- payConfig.select.alipay = []
- payConfig.select.wechat = []
- res.data.forEach(item => {
- if (item.type == 'alipay') {
- payConfig.select.alipay.push(item)
- }
- if (item.type == 'wechat') {
- payConfig.select.wechat.push(item)
- }
- })
- return false
- }, function (ret, res) { })
- }
- function onAddPayConfig() {
- Fast.api.open('shopro/pay_config/add?type=add', "添加", {
- callback() {
- getPayConfigSelect()
- }
- })
- }
- function onConfirm() {
- proxy.$refs['formRef'].validate((valid) => {
- if (valid) {
- Fast.api.ajax({
- url: `shopro/config/platform/platform/${state.platform}`,
- type: 'POST',
- data: form.model,
- }, function (ret, res) {
- Fast.api.close()
- }, function (ret, res) { })
- }
- });
- }
- onMounted(() => {
- getPayConfigSelect()
- getDetail()
- })
- return {
- state,
- form,
- onConfiguration,
- payConfig,
- onAddPayConfig,
- onConfirm,
- }
- }
- }
- createApp('platform', platform);
- },
- };
- return Controller;
- });
|