liukangdong
2024-07-16 28cde0020f9a5566fc6a92e3023e5687459bd48f
wxmini
已添加1个文件
已修改13个文件
395 ■■■■ 文件已修改
wechat_jiaxuan/api/index.js 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_jiaxuan/app.wxss 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_jiaxuan/pages/auth/auth.js 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_jiaxuan/pages/auth/auth.wxml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_jiaxuan/pages/calculator/index.js 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_jiaxuan/pages/calculator/index.wxml 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_jiaxuan/pages/calculator/index.wxss 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_jiaxuan/pages/index/index.js 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_jiaxuan/pages/index/index.wxml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_jiaxuan/static/icon/logo.png 补丁 | 查看 | 原始文档 | blame | 历史
wechat_staff/api/index.js 102 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_staff/project.private.config.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_staff/utils/config.js 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_staff/utils/request.js 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
wechat_jiaxuan/api/index.js
@@ -17,6 +17,14 @@
    data
  })
}
// ç»‘定手机号
export const binDingPhone = (data) => {
  return request({
    url: '/web/customer/binDingPhone',
    method: "POST",
    data
  })
}
// èŽ·å–å­—å…¸å€¼
export const getDictData = (data) => {
  return request({
wechat_jiaxuan/app.wxss
@@ -29,4 +29,40 @@
}
.arrow_right{
  width: 16rpx;
}
/*  */
.flex {
  display: flex;
}
.flex-c {
  display: flex;
  align-items: center;
}
.flex-cc {
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-cb {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.flex-ca {
  display: flex;
  align-items: center;
  justify-content: space-around;
}
.flex-1 {
  flex: 1;
}
.flex-column {
  flex-direction: column;
}
wechat_jiaxuan/pages/auth/auth.js
@@ -1,7 +1,7 @@
import {
  wxLoginCustomer,
  getDictData,
  getWxMiniPhone
  getWxMiniPhone,
  binDingPhone
} from '../../api/index'
Page({
@@ -36,6 +36,14 @@
      })
    })
  },
  loginIn() {
    const { agreementFalg } = this.data
    if(!agreementFalg) return wx.showToast({
      title: '请先阅读并同意相关协议',
      icon: 'none',
      duration: 2000
    })
  },
  getPhoneNumber (e) {
    console.log(e.detail)
    console.log(e.detail.iv)
@@ -44,37 +52,18 @@
    getWxMiniPhone({
      encryptedData: data.encryptedData,
      iv: data.iv,
      sessionKey: wx.getStorageSync('sessionKey'),
    })
  },
  loginIn() {
    const { agreementFalg } = this.data
    if(!agreementFalg) return wx.showToast({
      title: '请先阅读并同意相关协议',
      icon: 'none',
      duration: 2000
    })
    wx.login({
      success: (res) => {
        if (res.code) {
          // èŽ·å–åˆ°ç”¨æˆ·ç™»å½•å‡­è¯ code
          const code = res.code;
          wx.setStorageSync('code', res.code)
          // å°† code å‘送给后端服务器
          wxLoginCustomer({code}).then(ress => {
            wx.setStorageSync('token', ress.data.token)
            wx.setStorageSync('member', ress.data.member)
            wx.redirectTo({
              url: '/pages/index/index',
            })
      sessionKey: wx.getStorageSync('sessionKey') || data.iv,
    }).then(res => {
      binDingPhone({
        phone: res.data
      }).then((res) => {
        if(res.code == 200){
          wx.setStorageSync('member', res.data)
          wx.switchTab({
            url: '/pages/index/index',
          })
        } else {
          console.error('获取用户登录凭证失败', res.errMsg);
        }
      },
      fail: (err) => {
        console.error('调用 wx.login å¤±è´¥', err);
      },
      })
    })
  },
  onOpen(e){
wechat_jiaxuan/pages/auth/auth.wxml
@@ -16,7 +16,8 @@
          <text data-index="1" bindtap="onOpen" class="primary">《ZBOM用户隐私政策》</text>
        </view>
      </view>
      <button class="btn" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">手机号快捷登录</button>
      <button class="btn" wx:if="{{ !agreementFalg }}" bindtap="loginIn">手机号快捷登录</button>
      <button wx:else class="btn" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">手机号快捷登录</button>
    </view>
  </view>
  <!--  -->
wechat_jiaxuan/pages/calculator/index.js
@@ -1,7 +1,7 @@
// pages/calculator/index.js
// import { imageUrl } from '../../utils/config'
// import { calculatorOption, calculatorSave, decodePhone, bindPhone } from '../../api/index'
import { getBjParamConfig, saveRenovationCalculator } from '../../api/index'
import { getBjParamConfig, saveRenovationCalculator, getDictData, getWxMiniPhone, binDingPhone } from '../../api/index'
// import Ls from '../../utils/storage'
// let ls = new Ls
Page({
@@ -10,7 +10,7 @@
   * é¡µé¢çš„初始数据
   */
  data: {
    // background: imageUrl + 'calculator/background.jpg',
    background: '',
    userPhone: '',
    type: '',
    info: '',
@@ -21,7 +21,8 @@
      '一室一厅', '两室一厅', '两室两厅', '三室两厅',
      '四室两厅', '五室两厅及以上'
    ],
    calculatorOptions: [],
    calculatorOptions: {},
    activeList: [],
    showPopup: false,
    activePicker: '',
    pickerIndex: 0,
@@ -38,7 +39,6 @@
      that.setData({ userPhone: userInfo.phone })
    }
  },
  // è¿”回上一页
  navigateBack () {
    wx.navigateBack({
      delta: 1,
@@ -83,24 +83,21 @@
  
  // èŽ·å–ç”¨æˆ·æ‰‹æœºå·
  getPhoneNumber (e) {
    // console.log(e)
    let that = this
    decodePhone({ code: e.detail.code })
      .then(res => {
        if (res.phone === undefined || res.phone.length === null || !res.phone) {
          wx.showToast({
            title: res.msg,
            icon: 'none'
          })
        } else {
          bindPhone({ phone: res.phone })
            .then(newInfo => {
              ls.set('userInfo', newInfo.member)
              that.setData({ userPhone: res.phone })
              that.submit()
            })
    const data = { ...e.detail }
    getWxMiniPhone({
      encryptedData: data.encryptedData,
      iv: data.iv,
      sessionKey: wx.getStorageSync('sessionKey') || data.iv,
    }).then(res => {
      binDingPhone({
        phone: res.data
      }).then((res) => {
        if(res.code == 200){
          wx.setStorageSync('member', res.data)
          this.submit()
        }
      })
    })
  },
  // ç«‹å³è®¡ç®—
@@ -110,7 +107,7 @@
    const res = wx.getStorageSync('member')
    
    if (userPhone) {
      let { type, info, area, money, typeArray, infoArray, calculatorOptions: options } = this.data
      let { type, info, area, money, typeArray, infoArray, calculatorOptions } = this.data
      let submitData = {}
      submitData.name = res.name
      submitData.phone = res.phone
@@ -144,16 +141,34 @@
        return false
      }
      submitData = ['房屋类型:' + typeArray[type], '户型信息:' + infoArray[info], '房屋面积:' + area + '㎡', '装修预算:' + money + '万元'].join('-')
      for (let i in options) {
        options[i].money = (money * options[i].rate / 100).toFixed(2)
        let childList = options[i].childList
        for(let j in childList) {
          childList[j].money = (money * childList[j].rate / 100).toFixed(2)
      // submitData = ['房屋类型:' + typeArray[type], '户型信息:' + infoArray[info], '房屋面积:' + area + '㎡', '装修预算:' + money + '万元'].join('-')
      let activeList = type == '0' ? [...calculatorOptions.exquisiteList] : [...calculatorOptions.roughList]
      activeList.forEach(item => {
        item.money = (money * item.rate / 100).toFixed(1)
        if(item.children && item.children.length > 0){
          item.children.forEach(child => {
            child.money = (money * child.rate / 100).toFixed(2)
          })
        }
      }
      this.setData({ calculatorOptions: options, showResultMoney: true, containerContentStyle: 'auto' })
      this.submitCalculatorResult(submitData)
      })
      console.log('activeList', activeList);
      saveRenovationCalculator({
        area,
        budget: money,
        houseStatus: type,
        houseType: info
       }).then(res => {
        // console.log(res)
        if (res.success) {
          wx.showToast({
            title: '计算成功',
            icon: 'none'
          })
        } else {
          console.log(res.msg)
        }
      })
      this.setData({ activeList, showResultMoney: true, containerContentStyle: 'auto' })
    }
  },
@@ -177,6 +192,12 @@
    getBjParamConfig().then(res => {
      this.setData({ calculatorOptions: res.data })
    })
    getDictData({
      code: 'WEIXIN_DEFAULT_IMGS',
      label: 'JISUAN_BG'
    }).then(res => {
      this.setData({ background: res.data.code })
    })
  },
  onReady: function () {
wechat_jiaxuan/pages/calculator/index.wxml
@@ -1,7 +1,8 @@
<!--pages/calculator/index.wxml-->
<view class="container" style="background-image: {{ 'url(' + background + ')' }};">
<view class="container">
  <image class="main_bg" src="{{ background }}" mode="widthFix"></image>
  <view class="container-content" style="overflow-y: {{ containerContentStyle }};">
    <van-nav-bar border="{{ false }}" custom-class="top-head-transparent" bind:click-left="navigateBack" fixed placeholder>
    <van-nav-bar  title="装修计算器" border="{{ false }}" custom-class="top-head-transparent" bind:click-left="navigateBack" fixed placeholder>
      <van-icon name="arrow-left" class="top-head-icon" slot="left" />
    </van-nav-bar>
@@ -70,14 +71,14 @@
        <view class="td rate">参考比例</view>
        <view class="td money">参考价格</view>
      </view>
      <view class="item" wx:for="{{ calculatorOptions }}" wx:key="index"
      <view class="item" wx:for="{{ activeList }}" wx:key="index"
        hidden="{{ type == item.info }}">
        <view class="flex th">
          <view class="td name">{{ item.name }}</view>
          <view class="td rate">占比{{ item.rate }}%</view>
          <view class="td money">合计{{ item.money }}(万元)</view>
        </view>
        <view class="flex tr" wx:for="{{ item.childList }}" wx:for-item="ite" wx:for-index="idx" wx:key="idx">
        <view class="flex tr" wx:for="{{ item.children }}" wx:for-item="ite" wx:for-index="idx" wx:key="idx">
          <view class="td name">{{ ite.name }}</view>
          <view class="td rate">{{ ite.rate }}%</view>
          <view class="td money">{{ ite.money }}</view>
wechat_jiaxuan/pages/calculator/index.wxss
@@ -1,40 +1,22 @@
/* pages/calculator/index.wxss */
.container {
  color: #fff;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  position: relative;
  overflow: hidden;
  overflow: auto;
}
.container::before {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
.main_bg{
  position: fixed;
  top: 0;
  left: 0;
  background-color: rgba(255,255,255,0.5);
  position: absolute;
}
.container-content {
  background-color: rgba(0,0,0,0.75);
  position: absolute;
  height: 100%;
  width: 100%;
  left: 0;
  right: 0;
  z-index: -1;
}
.top-head-transparent {
  background-color: transparent!important;
  color: #222222 !important;
}
.top-head-transparent .van-icon.van-icon-arrow-left {
  font-size: 40rpx!important;
  color: #fff!important;
  color: #222222 !important;
}
.calculator {
@@ -49,7 +31,8 @@
.calculator .tips {
  font-size: 28rpx;
  margin-bottom: 70rpx;
  opacity: 0.8;
  font-weight: 300;
  color: #333333;
}
.calculator .form-item {
@@ -62,8 +45,7 @@
.calculator .input-box {
  display: flex;
  flex: 1;
  border: 1px solid #fff;
  background-color: rgba(0,0,0,0.1);
  border: 1px solid #B08771;
  padding: 0 40rpx;
  border-radius: 8rpx;
}
@@ -76,16 +58,15 @@
}
.calculator .input-box .placeholder {
  color: rgba(255,255,255,0.6);
  color: #999999;
}
.calculator .submit-btn {
  text-align: center;
  line-height: 100rpx;
  height: 100rpx;
  background: linear-gradient(180deg, #E0B49C 0%, #B68B74 100%);
box-shadow: 0rpx 4rpx 16rpx 0rpx rgba(176,135,113,0.3000), inset 0rpx 2rpx 2rpx 0rpx rgba(255,255,255,0.3300);
border-radius: 8rpx;
  background: #B08771;
  border-radius: 8rpx;
  width: 100%;
  font-size: 32rpx;
  color: #fff;
@@ -109,7 +90,9 @@
}
.results {
  background-color: #f7f7f7;
  position: relative;
  z-index: 1;
  background: #FFFFFF;
  color: #222;
  text-align: center;
  margin: 0 30rpx 60rpx;
wechat_jiaxuan/pages/index/index.js
@@ -1,4 +1,4 @@
import { getDictData } from '../../api/index'
import { getDictData, getMemberInfo } from '../../api/index'
Page({
  /**
@@ -9,6 +9,7 @@
    topHeadStyle: 1,
    showWhiteHead: true,
    topHeadBorder: false,
    member: {},
    
    bannerList: [
      {imgurl: ''},
@@ -31,6 +32,11 @@
  },
  toSearch() {},
  onShow() {
    getMemberInfo().then(res => {
      this.setData({member: res.data})
    })
  },
  onLoad(options) {
    this.initData()
  },
@@ -118,13 +124,6 @@
   * ç”Ÿå‘½å‘¨æœŸå‡½æ•°--监听页面初次渲染完成
   */
  onReady() {
  },
  /**
   * ç”Ÿå‘½å‘¨æœŸå‡½æ•°--监听页面显示
   */
  onShow() {
  },
wechat_jiaxuan/pages/index/index.wxml
@@ -35,7 +35,7 @@
    </view>
  </view>
  <!--  -->
  <authCard type="1" />
  <authCard type="{{ member.authStatus }}" />
  <!-- äº§å“è§†é¢‘  -->
  <view class="product_video" bindtap="jumpProVideo">
    <view class="com_header">
wechat_jiaxuan/static/icon/logo.png

wechat_staff/api/index.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,102 @@
import { request } from '../utils/request'
import { baseUrl } from '../utils/config'
export const uploadUrl = baseUrl + '/public/upload'
// å°ç¨‹åºç™»å½•
export const wxLoginCustomer = (data) => {
  return request({
    url: '/web/customer/wxLoginCustomer',
    data
  })
}
// èŽ·å–æ‰‹æœºå·
export const getWxMiniPhone = (data) => {
  return request({
    url: '/web/customer/getWxMiniPhone',
    method: "POST",
    data
  })
}
// ç»‘定手机号
export const binDingPhone = (data) => {
  return request({
    url: '/web/customer/binDingPhone',
    method: "POST",
    data
  })
}
// èŽ·å–å­—å…¸å€¼
export const getDictData = (data) => {
  return request({
    url: '/public/getDictData',
    data,
    loading: '0'
  })
}
// èŽ·å–ä¼šå‘˜ä¿¡æ¯
export const getMemberInfo = () => {
  return request({
    url: '/web/customer/getMemberInfo',
  })
}
// èŽ·å–é—¨åº—åˆ—è¡¨
export const getShopPage = (data) => {
  return request({
    url: '/web/customer/shopPage',
    method: 'POST',
    data
  })
}
// èŽ·å–é—¨åº—è¯¦æƒ…
export const getShopDetail = (data) => {
  return request({
    url: '/web/customer/shopDetail',
    data
  })
}
// æ›´æ–°ä¼šå‘˜ä¿¡æ¯
export const editMember = (data) => {
  return request({
    url: '/web/customer/editMember',
    method: 'POST',
    data
  })
}
// 0元定制信息
export const saveFreeCustomizationApply = (data) => {
  return request({
    url: '/web/customer/saveFreeCustomizationApply',
    method: 'POST',
    data
  })
}
// èŽ·å–è®¡ç®—å™¨é…ç½®
export const getBjParamConfig = (data) => {
  return request({
    url: '/web/customer/getBjParamConfig',
    data
  })
}
// ä¿å­˜è®¡ç®—器配置
export const saveRenovationCalculator = (data) => {
  return request({
    url: '/web/customer/saveRenovationCalculator',
    method: 'POST',
    data
  })
}
// èŽ·å–çœå¸‚åŒº
export const getArea = (data) => {
  return request({
    url: '/web/common/getArea',
    data
  })
}
// å°ç¨‹åºæ³¨é”€
export const wxLogOff = (data) => {
  return request({
    url: '/web/customer/logOff',
    data
  })
}
wechat_staff/project.private.config.json
@@ -10,7 +10,7 @@
      "list": [
        {
          "name": "",
          "pathName": "pages/store/index",
          "pathName": "pages/index/index",
          "query": "",
          "launchMode": "default",
          "scene": null
wechat_staff/utils/config.js
@@ -1,9 +1,8 @@
// export const baseUrl = 'https://jiaxuan.zbom.com/jx/wechat/' //正式服务器
export const baseUrl = 'http://192.168.0.124:8080/zbom/jx/wechat/' // æœ¬åœ°
export const baseUrl = 'http://192.168.0.135:10027' // æœ¬åœ°
// export const baseUrl = 'http://zbtest.ahapp.net/zbom_interface/jx/wechat/' //测试服务器
// export const imageUrl = 'https://osswebcdn.zbom.com/jiaxuan/images/'
wechat_staff/utils/request.js
@@ -1,26 +1,46 @@
import { baseUrl } from "./config"
export function request(options){
  let loading = options.loading || '1' // é»˜è®¤å€¼1显示,否则不显示
  if(loading == '1'){
    wx.showLoading()
  }
  return new Promise(resolve => {
    wx.request({
      url: baseUrl + options.url,
      data: options.options || {},
      data: options.data || {},
      method: options.method || "GET",
      header: {
        'content-type': 'application/x-www-form-urlencoded',
        'content-type': 'application/json;charset=utf-8',
        'token': wx.getStorageSync('token') || ''
      },
      timeout: 12000,
      success: (res) => {
        if (res.code === 0) {
          // res.msg && toast(res.msg)
        if (res.data.code === 200) {
          resolve(res.data || true)
        } else {
          res.msg && toast(res.msg || '发生错误', 'none')
          resolve(res.data || false)
          if(res.data.code && res.data.code == 5112){
            wx.navigateTo({
              url: '/pages/auth/auth',
            })
          }
          res.data.message && wx.showToast({
            title: res.data.message || '发生错误',
            icon: 'none'
          })
        }
      },
      fail() {
        wxToast('网络错误', 'none')
      fail(err) {
        console.log('err', err);
        err.message && wx.showToast({
          title: err.message || '发生错误',
          icon: 'none'
        })
      },
      complete() {
        if(loading == '1'){
          wx.hideLoading()
        }
      }
    })
  } )