gitweixin
  • 首页
  • 小程序代码
    • 资讯读书
    • 工具类
    • O2O
    • 地图定位
    • 社交
    • 行业软件
    • 电商类
    • 互联网类
    • 企业类
    • UI控件
  • 大数据开发
    • Hadoop
    • Spark
    • Hbase
    • Elasticsearch
    • Kafka
    • Flink
    • 数据仓库
    • 数据挖掘
    • flume
    • Kafka
    • Hive
    • shardingsphere
    • solr
  • 开发博客
    • Android
    • php
    • python
    • 运维
    • 技术架构
    • 数据库
  • 程序员网赚
  • bug清单
  • 量化投资
  • 在线查询工具
    • 去行号
    • 在线时间戳转换工具
    • 免费图片批量修改尺寸在线工具
    • SVG转JPG在线工具

月度归档4月 2021

精品微信小程序开发门户,代码全部亲测可用

  • 首页   /  2021   /  
  • 4月
数据仓库 4月 28,2021

关系型数据库(关系模型)转变为数据仓库(维度模型)示例

关系模型示意如图1所示,严格遵循第三范式(3NF)。从图1中可以看出,模型较为松散、零碎,物理表数量多,但数据冗余程度低。由于数据分布于众多的表中,因此这些数据可以更为灵活地被应用,功能性较强。关系模型主要应用于OLTP中,为了保证数据的一致性及避免冗余,大部分业务系统的表都是遵循第三范式的。

维度模型示意如图2所示,其主要应用于OLAP中,通常以某一张事实表为中心进行表的组织,主要面向业务,其特征是可能存在数据的冗余,但用户能方便地得到数据。关系模型虽然数据冗余程度低,但在大规模数据中进行跨表分析、统计、查询时,会造成多表关联,这会大大降低执行效率。所以通常我们采用维度模型建模,把各种相关表整理成事实表和维度表两种。所有的维度表围绕事实表进行解释。

图1 关系模型示意
图2 维度模型示意
作者 east
企业类 4月 23,2021

创客孵化器微信小程序代码

各地创客空间如雨后春笋,功能:

有图文的创客介绍。

入驻申请。项目基本信息、提交图片

预约看房。留下联系方式。

服务集市:各类记账等公司。

import util from './../../utils/util.js';
Page({
  data: {
    sortindex:0,  //排序索引
    sortid:null,  //排序id
    sort:[],
    activitylist:[], //会议室列表列表
    scrolltop:null, //滚动位置
    page: 0  //分页
  },
  onLoad: function () { //加载数据渲染页面
    this.fetchConferenceData();
    this.fetchSortData();
  },
  fetchSortData:function(){ //获取筛选条件
    this.setData({
      "sort": [
          {
              "id": 0,
              "title": "热门点击"
          },
          {
              "id": 1,
              "title": "最新发布"
          },
          {
              "id": 2,
              "title": "最多参与"
          },
      ]
    })
  },
  fetchConferenceData:function(){  //获取会议室列表
    const perpage = 10;
    this.setData({
      page:this.data.page+1
    })
    const page = this.data.page;
    const newlist = [];
    for (var i = (page-1)*perpage; i < page*perpage; i++) {
      newlist.push({
        "id":i+1,
        "name":"云栖技术分享日(云栖TechDay"+(i+1)+")",
        "status": util.getRandomArrayElement(["进行中","报名中","已结束"]),
        "time": "2016/07/12 14:00",
        "coments": Math.floor(Math.random()*1000),
        "address":"杭州云栖小镇咖啡馆  (杭州云计算产业园内)",
        "imgurl":"http://pic.58pic.com/58pic/12/34/51/85d58PICkjf.jpg"
      })
    }
    this.setData({
      activitylist:this.data.activitylist.concat(newlist)
    })
  },
  setSortBy:function(e){ //选择排序方式
    const d= this.data;
    const dataset = e.currentTarget.dataset;
    this.setData({
      sortindex:dataset.sortindex,
      sortid:dataset.sortid
    })
    console.log('排序方式id:'+this.data.sortid);
  },
  setStatusClass:function(e){ //设置状态颜色
    console.log(e);
  },
  scrollHandle:function(e){ //滚动事件
    this.setData({
      scrolltop:e.detail.scrollTop
    })
  },
  goToTop:function(){ //回到顶部
    this.setData({
      scrolltop:0
    })
  },
  scrollLoading:function(){ //滚动加载
    this.fetchConferenceData();
  },
  onPullDownRefresh:function(){ //下拉刷新
    this.setData({
      page:0,
      activitylist:[]
    })
    this.fetchConferenceData();
    this.fetchSortData();
    setTimeout(()=>{
      wx.stopPullDownRefresh()
    },1000)
  }
})

下载地址:工程代码

作者 east
开发博客 4月 17,2021

微信小程序语音识别、语音合成(微信同声传译)使用代码实例

最近在开发一款“单词大作战”的微信小程序,想增加语音识别、语音合成这2个功能。(让用户能听到单词的读音,并对比自己读音是否标准正确)。

查了一下资料,大概有几种方式:用百度翻译(需要配置后台来转发)、讯飞(听说效果最好,但好像要收费并要配置后台来转发 )。还有用微信同声传译插件。

微信同声传译插件使用最方便,目前功能还是尽善尽美,但一直在升级,是个人开发者不错的选择。用微信扫描下面小程序可以体验语音合成和语音识别的功能:

官方的开发文档:https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wx069ba97219f66d99&token=251348119&lang=zh_CN

使用步骤:

1、 在微信公众平台配置,找到设置–第三方设置–插件管理–点击添加插件,
搜索微信同声传译并添加

2、 在项目根目录app.json文件中配置

 "plugins": {
    "WechatSI": {
      "version": "0.3.4",
      "provider": "wx069ba97219f66d99"
    }
  },

语音合成:

在pages的js中加入插件初始化代码

const innerAudioContext = wx.createInnerAudioContext();
innerAudioContext.autoplay = true;
const plugin = requirePlugin('WechatSI');

由于语音合成原理是微信同声传译是在同声传译后台生产录音,下载播放录音。可以在页面加载阶段生产录音,在使用的地方播放录音,就不会有延迟。

//在全局定义变量
var remoteAudio = null;

//在开始阶段加载
 plugin.textToSpeech({
     lang: "en_US",
     tts: true,
     content: word,
     success: function(res) {
         console.log("succ tts", res.filename)   
        // this.playAudio(res.filename);
        remoteAudio = res.filename;
       
     },
     fail: function(res) {
         console.log("fail tts", res)
     }
 })
  },


//在实际需要使用语音合成地方
innerAudioContext.stop();
console.log("remoteAudio: " + remoteAudio);
innerAudioContext.src = remoteAudio;
innerAudioContext.play();
innerAudioContext.onError((e) => {
  console.log(e.errMsg)      
  console.log(e.errCode)      
  })

语音识别:

在pages的js中加入插件初始化代码

//引入插件:微信同声传译
const plugin = requirePlugin('WechatSI');
//获取全局唯一的语音识别管理器recordRecoManager
const manager = plugin.getRecordRecognitionManager();
// 设置采集声音参数
const options = {
  sampleRate: 44100,
  numberOfChannels: 1,
  encodeBitRate: 192000,
  format: 'aac'
}

在 onload()中加入初始化代码

//识别语音
this.initRecord();

在需要加入语音识别地方加入下面代码:

 //语音  --按住说话
  touchStart: function(e) {
    wx.vibrateShort() //按键震动效果(15ms)
    manager.start(options)
    this.setData({
      recordState: true, //录音状态为真
      tips: '松开结束',
    })

  },
  //语音  --松开结束
  touchEnd: function(e) {
    // 语音结束识别
    manager.stop();
    this.setData({
      recordState: false,
    })

  },
  //识别语音 -- 初始化
  initRecord: function() {
    const that = this;
    // 有新的识别内容返回,则会调用此事件
    manager.onRecognize = function(res) {
      console.log(res)
    }
    // 正常开始录音识别时会调用此事件
    manager.onStart = function(res) {
      console.log("成功开始录音识别", res)
    }
    // 识别错误事件
    manager.onError = function(res) {
      console.error("error msg:", res.retcode, res.msg)
    }
    //识别结束事件
    manager.onStop = function(res) {
      console.log('..............结束录音')
      console.log('录音总时长 -->' + res.duration + 'ms');
      console.log('语音内容 --> ' + res.result);
      if (res.result == '') {
        wx.showModal({
          title: '提示',
          content: '听不清楚,请重新说一遍!',
          showCancel: false,
          success: function(res) {}
        })
        return;
      }
      //下面有些代码有一些业务代码,要根据自己实际进行替换
      if(res.result == this.myword){
        that.setData({
          content: that.myword + '读音正确' //去掉自动添加的句号
        }) 
          next();
      }else{
        that.setData({
          recordState: false, //录音状态为真
          content: that.myword +'读音不准',
        })
        plugin.textToSpeech({
          lang: "en_US",
          tts: true,
          content: that.myword,
          success: function(res) {
              console.log("succ tts", res.filename)                
          },
          fail: function(res) {
              console.log("fail tts", res)
          }
      })
      }
    }
  },

 


作者 east
O2O 4月 6,2021

切换城市微信小程序代码

一款O2O的微信小程序,切换城市是最基本的组件。选择拼音,切换到全国各个市。

var city = require('../../utils/city.js');


Page({
  data: {
    searchLetter: [],
    showLetter: "",
    winHeight: 0,
    tHeight:0,
    bHeight:0,
    startPageY:0,
    cityList:[],
    isShowLetter:false,
    scrollTop:0,
    city:""
  },
  onLoad: function (options) {
    // 生命周期函数--监听页面加载
    var searchLetter = city.searchLetter;
    var cityList=city.cityList();
    // console.log(cityInfo);

    var sysInfo = wx.getSystemInfoSync();
    console.log(sysInfo);
    var winHeight = sysInfo.windowHeight;

    //添加要匹配的字母范围值
    //1、更加屏幕高度设置子元素的高度
    var itemH = winHeight / searchLetter.length;
    var tempObj = [];
    for (var i = 0; i < searchLetter.length; i++) {
      var temp = {};
      temp.name = searchLetter[i];
      temp.tHeight = i * itemH;
      temp.bHeight = (i + 1) * itemH;

      tempObj.push(temp)
    }
    
    this.setData({
      winHeight: winHeight,
      itemH: itemH,
      searchLetter: tempObj,
      cityList:cityList
    })

    console.log(this.data.cityInfo);
  },
  onReady: function () {
    // 生命周期函数--监听页面初次渲染完成

  },
  onShow: function () {
    // 生命周期函数--监听页面显示

  },
  onHide: function () {
    // 生命周期函数--监听页面隐藏

  },
  onUnload: function () {
    // 生命周期函数--监听页面卸载

  },
  onPullDownRefresh: function () {
    // 页面相关事件处理函数--监听用户下拉动作

  },
  onReachBottom: function () {
    // 页面上拉触底事件的处理函数

  },
  onShareAppMessage: function () {
    // 用户点击右上角分享
    return {
      title: 'title', // 分享标题
      desc: 'desc', // 分享描述
      path: 'path' // 分享路径
    }
  },
  searchStart: function (e) {
    var showLetter = e.currentTarget.dataset.letter;
    var pageY = e.touches[0].pageY;
    this.setScrollTop(this,showLetter);
    this.nowLetter(pageY,this);
      this.setData({
        showLetter: showLetter,
        startPageY: pageY,
        isShowLetter:true,
      })
  },
  searchMove: function (e) {
    var pageY = e.touches[0].pageY;
    var startPageY=this.data.startPageY;
    var tHeight=this.data.tHeight;
    var bHeight=this.data.bHeight;
    var showLetter = 0;
    console.log(pageY);
    if(startPageY-pageY>0){ //向上移动
        if(pageY<tHeight){
          // showLetter=this.mateLetter(pageY,this);
          this.nowLetter(pageY,this);
        }
    }else{//向下移动
        if(pageY>bHeight){
            // showLetter=this.mateLetter(pageY,this);
            this.nowLetter(pageY,this);
        }
    }
  },
  searchEnd: function (e) {
    // console.log(e);
    // var showLetter=e.currentTarget.dataset.letter;
    var that=this;
    setTimeout(function(){
      that.setData({
      isShowLetter:false
    })
    },1000)
    
  },
  nowLetter: function (pageY, that) {//当前选中的信息
    var letterData = this.data.searchLetter;
    var bHeight = 0;
    var tHeight = 0;
    var showLetter="";
    for (var i = 0; i < letterData.length; i++) {
      if (letterData[i].tHeight <= pageY && pageY<= letterData[i].bHeight) {
        bHeight = letterData[i].bHeight; 
        tHeight = letterData[i].tHeight;
        showLetter = letterData[i].name;
        break;
      }
    }

    this.setScrollTop(that,showLetter);

    that.setData({
      bHeight:bHeight,
      tHeight:tHeight,
      showLetter:showLetter,
      startPageY:pageY
      })
  },
  bindScroll:function(e){
    console.log(e.detail)
  },
  setScrollTop:function(that,showLetter){
      var scrollTop=0;
      var cityList=that.data.cityList;
      var cityCount=0;
      var initialCount=0;
      for(var i=0;i<cityList.length;i++){
         if(showLetter==cityList[i].initial){
           scrollTop=initialCount*30+cityCount*41;
            break;
         }else{
            initialCount++;
            cityCount+=cityList[i].cityInfo.length;
         }
      }

      that.setData({
        scrollTop:scrollTop
      })
  },
  bindCity:function(e){
    var city=e.currentTarget.dataset.city;
    this.setData({city:city})
  }
})

下载地址:工程地址

作者 east
工具类 4月 5,2021

辩论倒计时微信小程序源码

例如像美国大选那样的辩论,正反双方的发言都是有时间控制的。本微信小程序可以设置每次发言时间(立论、驳立论、质辩等的时间),而且可以设置提前15秒等提醒。

// pages/config/config.js
Page({
  data:{
    configs:{ // 初始化该对象值

    }
  },
  onLoad:function(options){
    // 页面初始化 options为页面跳转所带来的参数
    //读取缓存中的初始配置
    try {
        var configs = wx.getStorageSync('configs');
        this.setData({
          configs:configs
        })
    } catch (e) {
      console.log(e);
    }
  },
  onReady:function(){
    // 页面渲染完成
  },
  onShow:function(){
    // 页面显示
  },
  onHide:function(){
    // 页面隐藏
  },
  onUnload:function(){
    // 页面关闭
  },

  // 开关选择器事件
  switchChange:function(event){

    var id = event.currentTarget.id; //标识
    var configs = this.data.configs;
    var config = configs[id]; //获取之前的数据

    //如果对象不存在,创建一个新的对象
    if(!config){
        config = Object.create(null);
    }

    config.state = event.detail.value;
    
    configs[id] = config;

    this.setData({
      configs:configs
    });

    //把设置保存到缓存中中,便于计时页面的使用
    try {
        wx.setStorageSync('configs', configs);
    } catch (e) {
      console.log(e);
    }
  },

  // slider 事件
  sliderChange:function(event){
    var id = event.currentTarget.id; //标识
    var configs = this.data.configs;
    var config = configs[id]; //获取之前的数据
    
    //如果对象不存在,创建一个新的对象
    if(!config){
        config = Object.create(null);
    }

    config.time = event.detail.value;
    
    configs[id] = config;

    this.setData({
      configs:configs
    });
    //把设置保存到缓存中中,便于计时页面的使用
    try {
        wx.setStorageSync('configs', configs);
    } catch (e) {
      console.log(e);
    }
  },

  // 声音提醒 事件
  radioChange:function(event){
    var id = event.currentTarget.id; //标识
    var configs = this.data.configs;
    var config = configs[id]; //获取之前的数据
    
    //如果对象不存在,创建一个新的对象
    if(!config){
        config = Object.create(null);
    }

    config.voice = event.detail.value;
    
    configs[id] = config;

    this.setData({
      configs:configs
    });
    //把设置保存到缓存中中,便于计时页面的使用
    try {
        wx.setStorageSync('configs', configs);
    } catch (e) {
      console.log(e);
    }
  }

})

下载地址:工程代码

作者 east
电商类 4月 2,2021

东航订机票微信小程序源码

仿东航、携程等订票app。

订票:分单程、往返,可以订机票和酒店。查看具体航班,浏览酒店具体信息。

订单:下订单,微信支付,查看订单,修改订单。

let app = getApp();
let utils = require('../../utils/utils');
let dateFormat = require('../../utils/dateutil');
Page({
     data:{
        hasInvoice:false,
        hasCoupon:false,
        hasAgree:false,
        totalPrice: '--',
        nextStep: {
           btnWord: '去支付'
        },
        costDetail: {
           show: false
        },
        loading:true
   },
   //添加乘机人
   addp:function(e){
      this.refreshPassengerHandle();
      let passengerInfo= wx.getStorageSync('passengerInfo');
      if(this.productKey==passengerInfo.productKey){
        let passengerList=passengerInfo.passengerList;
        if(!passengerList||passengerList.length==0){
          wx.navigateTo({
            url: '../createTraveller/createTraveller?type=1'
           })
        }else{
           wx.navigateTo({
            url: '../selectpassengers/selectpassengers',
           })
        }
      }else{
        wx.navigateTo({
            url: '../createTraveller/createTraveller?type=1'
        })
      }
   },
   onLoad:function(params){
      if(this.loadCount>5)
      {
        app.message('请求失败!')
        return;
      }
      this.loadCount=this.loadCount||0;
      this.loadCount++;
      this.productKey=params.productKey;
      this.childrenNum=params.childrenNum;
      this.adultNum=params.adultNum;
      let that=this;

      app.globalData.afterLogin.then(()=>{
          app.post('api/Product/Booking',{
          ProductKey: this.productKey
          }).then((data)=>{
            if(this.isUnload)return;
            if(data.Code==4){
              app.login().then(()=>{
                this.onLoad(params);
              })
            }else if(data.Code==200){
              that.setBookingData(data.Data.BookingInfo);
            }

            that.setData({
              loading:false
            })
          }).catch(function(e){
            console.log(e);
          })

          this.setData({
            loading:true,
            childrenNum:this.childrenNum,
            adultNum:this.adultNum
          })
      })


   },

   setBookingData:function(bookingInfo){
      let that=this;
      let departureDate= dateFormat.formatDay(new Date(bookingInfo.PkgProductInfo.PkgProduct_Schedule[0].DepartureDate));
      let departureCityName = bookingInfo.PkgProductInfo.DepartureTravelCityName;
      let destinationCityName = bookingInfo.PkgProductInfo.DestinationCityName;
      let contactInfo=this.contactInfo= bookingInfo.ContactInfo||{};
      let invoiceInfo=this.invoiceInfo= contactInfo.InvoiceInfo||{};
      this.isInternational = bookingInfo.PkgProductInfo.IsInternational;
      let segLeg=bookingInfo.PkgProductInfo.PkgProduct_Segment.length-1;
      this.lastDepartureTime=bookingInfo.PkgProductInfo.PkgProduct_Segment[segLeg].DepartureTime;
      //获取价格信息
      (bookingInfo.PackageProductPriceInfoList||[]).forEach(function(item){
        switch(item.PriceType){
          case 0:
            that.flightAndHotelPrice=item.TotalAmount;
            break;
          case 3:
            that.taxPrice=item.TotalAmount;
            break;
        }
      })
      let totalPrice=this.getTotalPrice();
      let passengerList=bookingInfo.PassengerInfoList;
      this.passengerInfo={
          productKey:this.productKey,
          passengerList:passengerList,
          selectedPassengerList:[],
          childrenNum:this.childrenNum,
          adultNum:this.adultNum,
          lastDepartureTime:this.lastDepartureTime,
          isInternational:this.isInternational
      };
      wx.setStorageSync('passengerInfo',this.passengerInfo);
      this.setData({
          productName:bookingInfo.PkgProductInfo.ProductName,
          departureDate:departureDate,
          departureCityName:departureCityName,
          destinationCityName:destinationCityName,
          totalPrice:totalPrice,
          flightAndHotelPrice:this.flightAndHotelPrice,
          taxPrice:this.taxPrice,
          contactName:contactInfo.ReceivingName||'',
          contactPhone:contactInfo.MobilePhone||'',
          contactEmail:contactInfo.Email||'',
          invoiceTitle:invoiceInfo.Title||'',
          invoiceAddress:invoiceInfo.DetailAddress||'',
          postCode:invoiceInfo.PostCode||'',
          invoicePhone:invoiceInfo.MobilePhone||'',
          invoiceName:invoiceInfo.Name||'',
          isInternational:this.isInternational,
          passengerList:[]
      })
   },
   getSelectedPassengerList:function(list,selectedIds){
      let that=this;

      return (list||[]).filter(function(item){
        return selectedIds.indexOf(item.ID)>-1;
      }).map(function(item){
        let passengerType=utils.isChild(new Date(item.Birthday),that.lastDepartureTime)?'儿童':(utils.isAdult(new Date(item.Birthday),that.lastDepartureTime)?'成人':'婴儿');
        let name =utils.getName(item);
        return {
          id:item.ID,
          name:name,
          cardType:item.CardType,
          CardNo:item.CardNo,
          passengerType:passengerType
        }
      })
   }
   ,
   refreshPassengerHandle:function(){
      var that=this;
      app.globalData.refreshPassenger=function(){
        let passengerInfo= wx.getStorageSync('passengerInfo');
        if(that.productKey==passengerInfo.productKey){
          that.passengerInfo=passengerInfo;
          let passengerList=passengerInfo.passengerList;
          let selectedPassengerList=passengerInfo.selectedPassengerList;
          that.setData({
            passengerList:that.getSelectedPassengerList(passengerList,selectedPassengerList)
          })
          app.globalData.refreshPassenger=null;
        }
      }
   }
   ,
   getTotalPrice:function(){
       let totalPrice= Math.floor(((this.flightAndHotelPrice||0)+(this.taxPrice||0)-(this.couponPrice||0))*100)/100;
       return totalPrice>0?totalPrice:0;
   },

   inputChangeHandle:function(e){
      var key=e.currentTarget.id;
      var data={};
      data[key]=e.detail.value;
      this.setData(data);
   },

   bindKeyInput: function(e) {
      this.inputChangeHandle(e);
   }
   ,
    //开关函数
   switch1Change: function (e){
     this.inputChangeHandle(e);
  },

   // 遮罩层
 showMask:function(e){
    //  console.log(e)
     this.setData({
     modalhidden:false
     })
   },
   hiddenMask:function(e){
     this.setData({
     modalhidden:true
     })
   },

  //  活动弹窗
  showactivity:function(e){
    console.log(e)
      this.setData({
      activityhide:false
     })
  },
  deleteHandle:function(e){
    let id=e.currentTarget.dataset.id;
    let that=this;
    utils.confirm('是否删除旅客?',function(res){
      if(!res.confirm)return;
      that.passengerInfo.selectedPassengerList=that.passengerInfo.selectedPassengerList.filter(function(item){
        return item!=id;
      })
      wx.setStorageSync('passengerInfo',that.passengerInfo);
      let passengerList=that.data.passengerList.filter(function(item){
        return item.id!=id;
      })
      that.setData({
        passengerList:passengerList
      })
    })
  },
  editHandle:function(e){
    this.refreshPassengerHandle();
    var id=e.currentTarget.dataset.id;
    wx.navigateTo({
      url:'../createTraveller/createTraveller?type=1&id='+id
    })
  },

  //选择
  catchTapHandle:function(){

  },
  verify:function(value) {
      var total = this.adultNum * 1 + this.childrenNum * 1,
          msg = '',
          selectedLists=[],
          billShow=this.data.hasInvoice,
          hasAgree=this.data.hasAgree;
      let passengerInfo= wx.getStorageSync('passengerInfo');
      if(this.productKey==passengerInfo.productKey){
        let passengerList=passengerInfo.passengerList;
        let selectedPassengerList=passengerInfo.selectedPassengerList;
        selectedLists= passengerList.filter((item)=>{
          return selectedPassengerList.indexOf(item.ID)>-1;
        })
      }

      if (this.isInternational) {
          msg = this.verifyInterPassener(selectedLists);
      }
      else {
          msg = this.verifyPassener(selectedLists);
      }

      if(!hasAgree){
        return '同意须知项方能进行下一步预定!';
      }
      else if (msg)
          return msg;
      else if (selectedLists.length < total) {
          msg = '选择的旅客人数不能小于出行人数!';
      }else if(!value.contactName){
          msg = '联系人姓名为空!';
      }else if(!utils.verifyName(value.contactName)){
          msg = '联系人姓名格式错误!';
      }else if (!value.contactPhone) {
          msg = '联系人手机号为空!';
      }else if (!utils.verifyPhone(value.contactPhone)) {
          msg = '联系人手机号格式错误!'
      }else if (!value.contactEmail){
          msg = '联系人邮箱为空!'
      }else if (!utils.verifyEmail(value.contactEmail)){
          msg = '联系人邮箱格式错误!';
      }else if (billShow && !utils.isChinaOrNumbOrLett(value.invoiceTitle)) {
          msg = '发票抬头为空或包含特殊字符!';
      }else if (billShow && ! value.invoiceName) {
          msg = '发票收件人为空!';
      }else if (billShow && !utils.verifyName(value.invoiceName)){
          msg = '发票收件人格式错误!'
      }else if (billShow && !value.invoicePhone) {
          msg = '收件人电话号码为空!';
      }else if (billShow && !utils.verifyPhone(value.invoicePhone)) {
          msg = '收件人电话号码格式错误!';
      }else if (billShow && !utils.isChinaOrNumbOrLett(value.invoiceAddress)) {
          msg = '地址为空或包含特殊字符!';
      }else if (billShow && !value.postCode) {
          msg = '邮政编码为空!';
      }else if (billShow && !utils.verifyPostCode(value.postCode)) {
          msg = '邮政编码格式不正确!';
      }
      return msg;
  },
  verifyInterPassener:function(passengerLists) {
      let msg = '',
          selectChild=0,
          selectAdult=0;
      passengerLists.some((item)=> {
          if(item.Birthday){
              let birDay=new Date(dateFormat.timestamp(item.Birthday,1)),
                  nowDate=new Date();
              if(utils.isChild(birDay,this.lastDepartureTime)){
                  selectChild++;
              }else if(utils.isAdult(birDay,this.lastDepartureTime)){
                  selectAdult++;
              }

          }

          if (!item.PassengerNameEN || item.PassengerNameEN == '/')
              msg = '英文名为空!';
          else if (item.CardType == null||item.CardType==0)//国际旅客没有身份证
              msg = '证件号码为空!';
          else if (!item.CardNo)
              msg = '证件号为空!';
          else if (!item.CheckCity) {
              msg = '签发地为空!';
          }
          else if (!item.CheckDate) {
              msg = '签发日期为空!';
          }
          else if (!item.PassportExpireDate) {
              msg = '证件有效期为空!';
          }
          else if (!item.CountryCode) {
              msg = '国籍为空!';
          }
          else if (!item.Birthday)
              msg = '生日为空!';
          else if(item.CardType==1&&!utils.varifyPassport(item.CardNo)){
              msg='护照格式错误,其由5-15位的字母和数字组成!';
          }else if(!utils.verifyName_2(item.PassengerName)){
              msg='中文姓名格式错误!';
          }

          if (msg) {
              msg = item.PassengerName + msg
              return true;
          }
      })
      if(!msg){
          if(selectChild==0&&selectAdult==0)
              msg='请您添加旅客!';
          else if(selectAdult!=this.adultNum)
              msg='成人人数不匹配,请修改后重新提交';
          else if(selectChild!=this.childrenNum)
              msg='儿童人数不匹配,请修改后重新提交';
      }

      return msg;
  },
  verifyPassener:function(passengerLists) {
    var msg = '',
        selectChild=0,
        selectAdult=0;
    passengerLists.some((item)=> {
        if(item.Birthday){
            let birDay=new Date(dateFormat.timestamp(item.Birthday,1)),
                nowDate=new Date();
            if(utils.isChild(birDay,this.lastDepartureTime)){
                selectChild++;
            }else if(utils.isAdult(birDay,this.lastDepartureTime)){
                selectAdult++;
            }
        }

        if (!item.PassengerName)
            msg = '中文名为空!';
        else if (item.CardType == null)
            msg = '证件类型为空!'
        else if (!item.CardNo)
            msg = '证件号为空!';
        else if (!item.Birthday)
            msg = '生日为空!';
        else if(item.CardType==1&&!utils.varifyPassport(item.CardNo)){
            msg='护照格式错误,其由5-15位的字母和数字组成!';
        }else if(!utils.verifyName_2(item.PassengerName)){
            msg='中文姓名格式错误!';
        }
        if (msg) {
            msg = item.PassengerNameEN + msg
            return true;
        }
    })
    if(!msg){
        if(selectChild==0&&selectAdult==0)
            msg='请您添加旅客!';
        else if(selectAdult!=this.adultNum)
            msg='成人人数不匹配,请修改后重新提交';
        else if(selectChild!=this.childrenNum)
            msg='儿童人数不匹配,请修改后重新提交';
    }

    return msg;
  },
  agreeChange:function(e){
    var key=e.currentTarget.id;
    var data={};
    data[key]=!this.data[key];
    this.setData(data);
  },

  //表单验证
  formBindsubmit:function(e){
    var value=e.detail.value;
    var msg=this.verify(value);
    if(msg){
      utils.message(msg);
    }else{
      app.globalData.afterLogin.then(()=>{
          let passengerInfo= wx.getStorageSync('passengerInfo');
          let selectedPassengerList=[];
          let hasInvoice=this.data.hasInvoice;
          let contactInfo=Object.assign({},this.contactInfo,{
              ReceivingName:value.contactName,
              MobilePhone:value.contactPhone,
              Email:value.contactEmail
          })
          let invoiceInfo;
          if(hasInvoice){
            invoiceInfo=Object.assign({},this.invoiceInfo,{
                DetailAddress:value.invoiceAddress,
                Name:value.invoiceName,
                MobilePhone:value.invoicePhone,
                Title:value.invoiceTitle,
                PostCode:value.postCode
            })
          }

          contactInfo.InvoiceInfo=invoiceInfo;

          if(this.productKey==passengerInfo.productKey){
              selectedPassengerList=passengerInfo.selectedPassengerList;
          }
          utils.loadingShow();
          if(this.loading)return;
          this.loading=true;
          app.post('api/Order/CreateOrder',{
            ProductKey: this.productKey,
            PassengerIDList: selectedPassengerList,
            ContactInfo: contactInfo,
            CouponIDList: [],
            CouponCodeList:[],
            Point:0
          }).then((data)=>{
            this.loading=false;
            if(this.isUnload)return;
            wx.hideToast();
            if(data.Code==4){
              app.login().then(()=>{
                utils.message('网络请求失败,请重新提交!');
              })
            }else if(data.Code==200){
              this.goPay(data.Data);
              let fn=app.globalData.reloadOrderList;
              if(typeof fn=='function'){
                setTimeout(fn,0);
              }
            }else if(data.Msg){
              utils.message(data.Msg);
            }
          }).catch((e)=>console.log(e))
      }).catch((e)=>console.log(e))
    }
  },
  goPay:function(data){
    wx.requestPayment({
      'timeStamp': data.TimeStamp,
      'nonceStr': data.NonceStr,
      'package': data.Package,
      'signType': data.SignType,
      'paySign': data.PaySign,
      success: ()=>{
        utils.message('支付成功!',function(){
          wx.switchTab({
            url: '../orderlist/orderlist'
          })
        })
      },
      fail: ()=>{
        utils.message('支付失败!');
      }
    })
  }
  ,
  showCostDetail(){
    this.setData({
      costDetail: {
        show: true
      }
    })
  },

  hideCostDetail(){
    this.setData({
      costDetail: {
        show: false
      }
    })
  },
  onUnload:function(){
    this.isUnload=true;
  }
})

下载地址:工程代码

作者 east
电商类 4月 1,2021

仿车源宝微信小程序代码

这是一款车辆交易平台。功能如下:

发布车源、户准寻车、我的订单、通知信息,车源管理、物流管理、车商金融、车市头条。

车源显示热门品牌,同时像微信通讯录一样按字母区分。

<view class="home-wrap">
  <swiper indicator-dots="true" autoplay="{{autoplay}}" duration="{{duration}}" interval="{{interval}}">
    <view wx:for="{{banner}}" wx:key="unique">
      <swiper-item>
        <view>
          <navigator url="{{item.target}}"><image src="{{item.image}}" mode="scaleToFill center" class="banner"></image></navigator>
        </view>
      </swiper-item>
    </view>
  </swiper>
  <view class="scroll-txt">
    <text class="scroll-ads">{{txtAds.title}}</text>
  </view>
  <view class="ads-list">
    <view class="ads-item" wx:for="{{advertise}}" wx:key="unique" wx:for-item="item">
      <image src="{{item.image}}" mode="scaleToFill center" class="sub-banner"></image>
    </view>
  </view>
  <view class="workbench">
    <text class="title">工作台</text>
    <view class="list">
      <view class="items">
        <image src="../../images/desk_publish@2x.png"></image>
        <text>发布车源</text>
      </view>
      <view class="items">
        <image src="../../images/desk_bid@2x.png"></image>
        <text>户准寻车</text>
      </view>
      <view class="items">
        <image src="../../images/desk_order@2x.png"></image>
        <text>我的订单</text>
      </view>
      <view class="items">
        <image src="../../images/desk_massage@2x.png"></image>
        <text>通知消息</text>
      </view>
    </view>
  </view>
  <view class="workbench">
    <text class="title">服务</text>
    <view class="list">
      <view class="items">
        <image src="../../images/home_car_source@2x.png" class="service-icon"></image>
        <text>车源管理</text>
      </view>
      <view class="items">
        <image src="../../images/home_logistical@2x.png" class="service-icon"></image>
        <text>物流管理</text>
      </view>
      <view class="items">
        <image src="../../images/home_finance@2x.png" class="service-icon"></image>
        <text>车商金融</text>
      </view>
      <view class="items">
        <image src="../../images/home_headlines@2x.png" class="service-icon"></image>
        <text>车市头条</text>
      </view>
    </view>
  </view>
</view>

下载地址:工程代码

作者 east

关注公众号“大模型全栈程序员”回复“小程序”获取1000个小程序打包源码。回复”chatgpt”获取免注册可用chatgpt。回复“大数据”获取多本大数据电子书

标签

AIGC AI创作 bert chatgpt github GPT-3 gpt3 GTP-3 hive mysql O2O tensorflow UI控件 不含后台 交流 共享经济 出行 图像 地图定位 外卖 多媒体 娱乐 小程序 布局 带后台完整项目 开源项目 搜索 支付 效率 教育 日历 机器学习 深度学习 物流 用户系统 电商 画图 画布(canvas) 社交 签到 联网 读书 资讯 阅读 预订

官方QQ群

小程序开发群:74052405

大数据开发群: 952493060

近期文章

  • 详解Python当中的pip常用命令
  • AUTOSAR如何在多个供应商交付的配置中避免ARXML不兼容?
  • C++thread pool(线程池)设计应关注哪些扩展性问题?
  • 各类MCAL(Microcontroller Abstraction Layer)如何与AUTOSAR工具链解耦?
  • 如何设计AUTOSAR中的“域控制器”以支持未来扩展?
  • C++ 中避免悬挂引用的企业策略有哪些?
  • 嵌入式电机:如何在低速和高负载状态下保持FOC(Field-Oriented Control)算法的电流控制稳定?
  • C++如何在插件式架构中使用反射实现模块隔离?
  • C++如何追踪内存泄漏(valgrind/ASan等)并定位到业务代码?
  • C++大型系统中如何组织头文件和依赖树?

文章归档

  • 2025年6月
  • 2025年5月
  • 2025年4月
  • 2025年3月
  • 2025年2月
  • 2025年1月
  • 2024年12月
  • 2024年11月
  • 2024年10月
  • 2024年9月
  • 2024年8月
  • 2024年7月
  • 2024年6月
  • 2024年5月
  • 2024年4月
  • 2024年3月
  • 2023年11月
  • 2023年10月
  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年6月
  • 2023年5月
  • 2023年4月
  • 2023年3月
  • 2023年1月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年7月
  • 2018年6月

分类目录

  • Android (73)
  • bug清单 (79)
  • C++ (34)
  • Fuchsia (15)
  • php (4)
  • python (43)
  • sklearn (1)
  • 云计算 (20)
  • 人工智能 (61)
    • chatgpt (21)
      • 提示词 (6)
    • Keras (1)
    • Tensorflow (3)
    • 大模型 (1)
    • 智能体 (4)
    • 深度学习 (14)
  • 储能 (44)
  • 前端 (4)
  • 大数据开发 (488)
    • CDH (6)
    • datax (4)
    • doris (30)
    • Elasticsearch (15)
    • Flink (78)
    • flume (7)
    • Hadoop (19)
    • Hbase (23)
    • Hive (40)
    • Impala (2)
    • Java (71)
    • Kafka (10)
    • neo4j (5)
    • shardingsphere (6)
    • solr (5)
    • Spark (99)
    • spring (11)
    • 数据仓库 (9)
    • 数据挖掘 (7)
    • 海豚调度器 (10)
    • 运维 (34)
      • Docker (3)
  • 小游戏代码 (1)
  • 小程序代码 (139)
    • O2O (16)
    • UI控件 (5)
    • 互联网类 (23)
    • 企业类 (6)
    • 地图定位 (9)
    • 多媒体 (6)
    • 工具类 (25)
    • 电商类 (22)
    • 社交 (7)
    • 行业软件 (7)
    • 资讯读书 (11)
  • 嵌入式 (70)
    • autosar (63)
    • RTOS (1)
    • 总线 (1)
  • 开发博客 (16)
    • Harmony (9)
  • 技术架构 (6)
  • 数据库 (32)
    • mongodb (1)
    • mysql (13)
    • pgsql (2)
    • redis (1)
    • tdengine (4)
  • 未分类 (6)
  • 程序员网赚 (20)
    • 广告联盟 (3)
    • 私域流量 (5)
    • 自媒体 (5)
  • 量化投资 (4)
  • 面试 (14)

功能

  • 登录
  • 文章RSS
  • 评论RSS
  • WordPress.org

All Rights Reserved by Gitweixin.本站收集网友上传代码, 如有侵犯版权,请发邮件联系yiyuyos@gmail.com删除.