| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- "id": "2026031010523201",
- list: [],
- content: {
- isAll: false,
- nocache: true,
- pageNumber: 1,
- pageSize: 20,
- pageTotal: 1,
- where: {
- condition: ""
- }
- }
- },
- onLoad() {
- this.getList();
- },
- onShow() {
- if (this.data._loaded) {
- this.getList(true);
- }
- this.setData({ _loaded: true });
- },
- /* 获取门店列表 */
- getList(init = false) {
- if (init.detail != undefined) init = init.detail;
- if (init) {
- this.setData({
- 'content.pageNumber': 1
- });
- }
- if (this.data.content.pageNumber > this.data.content.pageTotal) return;
- this.setListHeight();
- _Http.basic({
- id: this.data.id,
- content: this.data.content
- }).then(res => {
- console.log("门店列表数据", res);
- this.selectComponent('#ListBox').RefreshToComplete();
- this.setData({
- 'content.pageNumber': res.pageNumber + 1,
- 'content.pageTotal': res.pageTotal,
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
- total: res.total
- });
- }).catch(err => {
- console.error("获取门店列表失败", err);
- this.selectComponent('#ListBox').RefreshToComplete();
- wx.showToast({
- title: '获取门店列表失败',
- icon: 'none'
- });
- });
- },
- /* 设置页面高度 */
- setListHeight() {
- this.selectComponent("#ListBox").setHeight(".header", this);
- },
- /* 搜索 */
- onSearch({ detail }) {
- this.setData({
- 'content.where.condition': detail
- });
- this.getList(true);
- },
- /* 跳转到详情页 */
- goToDetail(e) {
- const id = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: `./detail?id=${id}`
- });
- },
- /* 跳转新建门店 */
- goToCreate() {
- wx.navigateTo({
- url: '/CRM/myStore/create'
- });
- },
- /* 编辑 */
- onEdit(e) {
- const item = e.currentTarget.dataset.item;
- _Http.detail = item;
- wx.navigateTo({
- url: '/CRM/myStore/create?edit=true'
- });
- },
- /* 启用申请 */
- onApplyEnable(e) {
- const item = e.currentTarget.dataset.item;
- wx.showModal({
- title: '门店启用申请',
- content: '确定要启用该门店吗?',
- success: (res) => {
- if (res.confirm) {
- _Http.basic({
- id: '2026031011291801',
- content: {
- shoplistid: item.sa_storeid,
- type: 'enable'
- }
- }).then(res => {
- if (res.code == 1) {
- wx.showToast({ title: '申请提交成功', icon: 'none' });
- this.getList(true);
- } else {
- wx.showToast({ title: res.msg || '操作失败', icon: 'none' });
- }
- }).catch(() => {
- wx.showToast({ title: '网络错误', icon: 'none' });
- });
- }
- }
- });
- },
- /* 停用申请 */
- onApplyDisable(e) {
- const item = e.currentTarget.dataset.item;
- wx.showModal({
- title: '门店停用申请',
- content: '确定要停用该门店吗?',
- success: (res) => {
- if (res.confirm) {
- _Http.basic({
- id: '2026031011291801',
- content: {
- shoplistid: item.sa_storeid,
- type: 'disable'
- }
- }).then(res => {
- if (res.code == 1) {
- wx.showToast({ title: '申请提交成功', icon: 'none' });
- this.getList(true);
- } else {
- wx.showToast({ title: res.msg || '操作失败', icon: 'none' });
- }
- }).catch(() => {
- wx.showToast({ title: '网络错误', icon: 'none' });
- });
- }
- }
- });
- },
- /* 删除 */
- onDelete(e) {
- const item = e.currentTarget.dataset.item;
- wx.showModal({
- title: '提示',
- content: '确定要删除该门店吗?',
- success: (res) => {
- if (res.confirm) {
- _Http.basic({
- id: '2026031013094201',
- content: {
- sa_storeid: item.sa_storeid
- }
- }).then(res => {
- if (res.code == 1) {
- wx.showToast({ title: '删除成功', icon: 'none' });
- this.getList(true);
- } else {
- wx.showToast({ title: res.msg || '操作失败', icon: 'none' });
- }
- }).catch(() => {
- wx.showToast({ title: '网络错误', icon: 'none' });
- });
- }
- }
- });
- }
- });
|