123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717 |
- import {
- Home
- } from '../../utils/home.js';
- var home = new Home();
- var app = getApp();
- Page({
-
- data: {
- goodsType:[["课程","教程","商品"]],
- goodsTypeIndex:0,
- temp: [],
- isShow_goodsType:false,
- isShow_goods: false,
- isShow_campusName:false,
- picker_01_data: [],
- nickName: "",
- avatarUrl: "",
- qkong: false,
- campusNameListIndex: 0,
- selectType: true,
- goodsListIndex: 0,
- goodsList: [
- []
- ],
-
- num_: 0,
-
- sellPrice: 0,
-
- num: 0,
-
- prePrice: 0,
-
- weichatPay: 0,
-
- aliPay: 0,
-
- cashPay: 0,
-
- weidianPay: 0,
-
- pledgeDeduction: 0,
-
- campusPay: '',
-
- comment: '',
- userName: '',
- mobile: '',
- pnumber: 1,
- Gender: 'female',
- casIndex: 0,
- casIndexx: 0,
- hiddenName: false,
- isDelivery: '已交付',
- deliverys: false,
- inputValue: null,
- weichatPay: 0,
- aliPay: 0,
- cashPay: 0,
- weidianPay: 0,
- pledgeDeduction: 0,
- campusPay: 0,
- jiaofeiren: '',
- items: [{
- value: '新',
- },
- {
- value: '老',
- },
- {
- value: 'U转吉',
- },
- {
- value: '吉转吉',
- },
- {
- value: '无',
- }
- ]
- },
- showPicker_campusName: function () {
- this.setData({
- isShow_campusName: true
- })
- },
-
-
-
-
-
-
- sureCallBack_campusName(e) {
- let that = this
- that.setData({
- isShow_campusName: false,
- campusNameListIndex: e.detail.choosedIndexArr[0]
- })
- },
- cancleCallBack_campusName() {
- let that=this
- that.data.isShow_campusName=false,
- that.setData({
- isShow_campusName: false,
- })
- },
- showPicker_goodsList: function() {
- let that=this
- that.data.isShow_goods= true
- that.setData({
- isShow_goods: true
- })
- },
- sureCallBack_goods(e) {
- let that = this
- if (that.data.objectGoodsList[e.detail.choosedIndexArr[0]].goods_tags == '商品') {
- that.setData({
- selectType: true,
- num_: 0
- })
- } else {
- that.setData({
- selectType: false,
- isDelivery: '已交付',
- num_: 1,
- num: 0
- })
- }
- that.setData({
- isShow_goods: false,
- goodsListIndex: e.detail.choosedIndexArr[0]
- })
- that.sellPrice()
- },
- cancleCallBack_goods() {
- this.setData({
- isShow_goods: false,
- })
- },
- showPicker_goodsTypeList: function () {
- this.setData({
- isShow_goodsType: true
- })
- },
- sureCallBack_goodsType(e) {
- let that = this
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- that.setData({
- goodsListIndex: 0
- })
- that.data.goodsTypeIndex=e.detail.choosedIndexArr[0]
- that.setData({
- isShow_goodsType: false,
- goodsTypeIndex: e.detail.choosedIndexArr[0]
- })
- that.getGoodList()
- },
- cancleCallBack_goodsType() {
- this.setData({
- isShow_goodsType: false,
- })
- },
-
- inputStudentName: function(e) {
- let that = this
- that.setData({
- studentName: e.detail.value
- })
- },
-
- radioChange: function(e) {
- let that = this
- this.setData({
- studentStatus: e.detail.value,
- })
- },
-
- bindPickerChangeGoodsList: function(e) {
- let that = this
- if (that.data.objectGoodsList[e.detail.value].goods_tags == '商品') {
- that.setData({
- selectType: true,
- num_: 0
- })
- } else {
- that.setData({
- selectType: false,
- isDelivery: '已交付',
- num_: 1,
- num: 0
- })
- }
- this.setData({
- goodsListIndex: e.detail.value
- })
- that.sellPrice()
- },
-
- sellPrice: function() {
- let that = this
- var sellPrice = that.data.objectGoodsList[that.data.goodsListIndex]['goods_price'] * that.data.num + that.data.objectGoodsList[that.data.goodsListIndex]['goods_price'] * that.data.num_
- that.setData({
- sellPrice: sellPrice,
- })
- },
-
- delivery: function(e) {
- var that = this;
- var b = this.data.isDelivery == "已交付" ? "未交付" : "已交付";
- if (b) {
- that.setData({
- isDelivery: b,
- 'inputValue': '',
- weichatPay: 0,
- aliPay: 0,
- cashPay: 0,
- weidianPay: 0,
- pledgeDeduction: 0,
- campusPay: 0,
- prePrice: 0
- })
- } else {
- that.setData({
- isDelivery: b,
- 'inputValue': '',
- })
- }
- },
- deliveryChange: function() {
- },
-
- numberInput: function(event) {
- let that = this;
- var inputSearch = event.detail.value;
- if (inputSearch.length > 0) {
- that.setData({
- deliverys: true,
- num: event.detail.value,
- prePrice: 0
- })
- } else {
- that.setData({
- deliverys: false,
- num: event.detail.value
- })
- }
- that.sellPrice()
- },
-
- prePriceInput: function() {
- let that = this
- if (that.data.num < 1) {
- let prePrice = 0
- prePrice = parseFloat(that.data.weichatPay) + parseFloat(that.data.aliPay) + parseFloat(that.data.cashPay) + parseFloat(that.data.weidianPay) + parseFloat(that.data.pledgeDeduction) + parseFloat(that.data.campusPay)
- that.setData({
- prePrice: prePrice
- })
- }
- },
-
- weichatPayInput: function(e) {
- let that = this
- that.setData({
- weichatPay: that.checkInputText(e.detail.value)
- })
- that.prePriceInput()
- },
-
- aliPayInput: function(e) {
- let that = this
- that.setData({
- aliPay: that.checkInputText(e.detail.value)
- })
- that.prePriceInput()
- },
-
- cashPayInput: function(e) {
- let that = this
- that.setData({
- cashPay: that.checkInputText(e.detail.value)
- })
- that.prePriceInput()
- },
-
- weidianPayInput: function(e) {
- let that = this
- that.setData({
- weidianPay: that.checkInputText(e.detail.value)
- })
- that.prePriceInput()
- },
-
- pledgeDeductionInput: function(e) {
- let that = this
- that.setData({
- pledgeDeduction: that.checkInputText(e.detail.value)
- })
- that.prePriceInput()
- },
-
- campusPayInput: function(e) {
- let that = this
- that.setData({
- campusPay: that.checkInputText(e.detail.value)
- })
- that.prePriceInput()
- },
-
- commentInput: function(e) {
- let that = this
- that.setData({
- comment: e.detail.value
- })
- },
- time: function() {
- let that = this
-
- var timestamp = Date.parse(new Date());
- timestamp = timestamp / 1000;
-
- var n = timestamp * 1000;
- var date = new Date(n);
-
- var Y = date.getFullYear();
-
- var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1);
-
- var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
-
- var h = date.getHours();
-
- var m = date.getMinutes();
-
- var s = date.getSeconds();
- that.setData({
- Y: Y,
- M: M,
- D: D,
- })
- },
-
- getGoodList: function() {
- let that = this
- var param = {goods_type:that.data.goodsType[0][that.data.goodsTypeIndex]}
- home.getGoodList(param, (res) => {
- that.setData({
- objectGoodsList: res.data
- })
- var glist = [[]];
- res.data.forEach((res) => {
- let that = this
-
- glist[0].push(res.goods_name)
-
- if (that.data.objectGoodsList[that.data.goodsListIndex].goods_tags == '商品') {
- that.setData({
- selectType: true
- })
- } else {
- that.setData({
- selectType: false
- })
- }
- })
- that.setData({ goodsList:glist})
- that.sellPrice()
- })
- },
-
- submit: function() {
- let that = this
- if (that.data.studentName) {
- if (that.data.studentStatus) {
- if (that.data.num || that.data.isDelivery || that.data.objectGoodsList[that.data.goodsListIndex].goods_tags == '课程') {
- if (that.data.prePrice || (that.data.weichatPay || that.data.aliPay || that.data.cashPay || that.data.weidianPay || that.data.pledgeDeduction || that.data.campusPay)) {
-
- var total = parseFloat(that.data.weichatPay) + parseFloat(that.data.aliPay) + parseFloat(that.data.cashPay) + parseFloat(that.data.weidianPay) + parseFloat(that.data.pledgeDeduction) + parseFloat(that.data.campusPay);
- if (that.data.sellPrice == total || that.data.isDelivery == "未交付") {
- var isDelivery = that.data.isDelivery;
- var prePrice = that.data.prePrice;
- if (that.data.objectGoodsList[that.data.goodsListIndex].goods_type == '课程') {
- isDelivery = '已交付'
- prePrice = 0
- }
- var param = {
-
- user_id: that.data.user_id,
-
- user_name: that.data.user_name,
-
- campusName: that.data.campusNameList[0][that.data.campusNameListIndex],
-
- studentName: that.data.studentName,
-
- studentStatus: that.data.studentStatus,
-
- goods: that.data.goodsList[0][that.data.goodsListIndex],
-
- sellPrice: that.data.sellPrice,
-
- num: that.data.num,
-
- isDelivery: isDelivery,
-
- prePrice: prePrice,
-
- weichatPay: that.data.weichatPay,
-
- aliPay: that.data.aliPay,
-
- cashPay: that.data.cashPay,
-
- weidianPay: that.data.weidianPay,
-
- pledgeDeduction: that.data.pledgeDeduction,
-
- campusPay: that.data.campusPay,
-
- comment: that.data.comment,
- }
- home.submit(param, (res) => {
- let that = this
- if (res.code == 1) {
- wx.showToast({
- title: res.msg,
- icon: 'none',
- duration: 1000,
- mask: true,
- success: function(res) {},
- fail: function(res) {},
- complete: function(res) {
- that.setData({
-
- user_id: '',
-
- user_name: '',
-
- campusName: that.data.campusNameList[that.data.campusNameListIndex],
- campusNameListIndex: 0,
-
- studentName: '',
-
- studentStatus: '',
-
- goods: that.data.goodsList[0][that.data.goodsListIndex],
- goodsListIndex: 0,
-
- sellPrice: 0,
-
- num: 0,
-
- isDelivery: '已交付',
-
- prePrice: 0,
-
- weichatPay: 0,
-
- aliPay: 0,
-
- cashPay: 0,
-
- weidianPay: 0,
-
- pledgeDeduction: 0,
-
- campusPay: 0,
-
- comment:'',
- qkong: true,
- jiaofeiren: '',
- deliverys: false
- })
- that.onShow()
- },
- })
- } else if (res.code == 0) {
- wx.showToast({
- title: res.msg,
- icon: 'none',
- duration: 1000,
- mask: true,
- success: function(res) {},
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- })
- } else if (that.data.sellPrice < total) {
- wx.showToast({
- title: '支付金额大于销售金额',
- icon: 'none',
- image: '',
- duration: 1000,
- mask: true,
- success: function(res) {},
- fail: function(res) {},
- complete: function(res) {},
- })
- } else if (that.data.sellPrice > total) {
- wx.showToast({
- title: '支付金额小于销售金额',
- icon: 'none',
- image: '',
- duration: 1000,
- mask: true,
- success: function(res) {},
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- } else {
- wx.showToast({
- title: '请填写支付金额',
- icon: 'none',
- image: '',
- duration: 1000,
- mask: true,
- success: function(res) {},
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- } else {
- wx.showToast({
- title: '请填写商品数量',
- icon: 'none',
- image: '',
- duration: 1000,
- mask: true
- })
- }
- } else {
- wx.showToast({
- title: '请选择学生状态',
- icon: 'none',
- image: '',
- duration: 1000,
- mask: true,
- success: function(res) {},
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- } else {
- wx.showToast({
- title: '请填写缴费人姓名',
- icon: 'none',
- image: '',
- duration: 1000,
- mask: true,
- success: function(res) {},
- fail: function(res) {},
- complete: function(res) {},
- })
- }
- },
-
- campus: function() {
- var that = this
- var params = {}
- home.campus(params, (res) => {
- var list=[[]]
- list[0]=res.data
- that.setData({
- campusNameList: list
- })
- })
- },
- onLoad: function() {
- },
-
- onReady: function() {
- },
-
- onShow: function() {
- let that = this
- that.time()
- that.prePriceInput()
- that.campus()
- var user_name = wx.getStorage({
- key: 'user_name',
- success: function(res) {
- that.setData({
- user_name: res.data
- })
- },
- })
- wx.getStorage({
- key: 'user_id',
- success: function(res) {
- that.setData({
- user_id: res.data
- })
- },
- })
- that.setData({
- objectGoodsList: [],
- goodsList: [
- []
- ]
- })
- home.getTime({}, (res) => {
- that.setData({
- goodsType: res.data.cates,
- })
- that.getGoodList();
- })
- },
-
- onHide: function() {
- },
-
- onUnload: function() {
- },
-
- onPullDownRefresh: function() {
- },
-
- onReachBottom: function() {
- },
-
- checkInputText: function (text) {
- var reg = /^(\.*)(\d+)(\.?)(\d{0,2}).*$/g;
- if (reg.test(text)) {
- text = text.replace(reg, '$2$3$4');
- } else {
- text = '';
- }
- if (text.substr(0,2) == '00') {
- text = text.substr(1, text.length);
- }
- if (text.substr(0, 1) == '0' && text.substr(1, 1) != '0' && text.substr(1, 1) != '.' && text.length>=2){
- text = text.substr(1, text.length);
- }
- return text;
- }
- })
|