开始做充值和发票
This commit is contained in:
		| @@ -1,3 +1,4 @@ | ||||
| import { getMeterDetail } from "../../service/meter"; | ||||
| import { getGlobalData, showModal } from "../../utils/index"; | ||||
|  | ||||
| // pages/recharge/index.js | ||||
| @@ -7,22 +8,29 @@ Page({ | ||||
|    * 页面的初始数据 | ||||
|    */ | ||||
|   data: { | ||||
|     code: "", | ||||
|     money: 0, | ||||
|     moneyIndex: -1, | ||||
|     primaryColor: getGlobalData().primaryColor, | ||||
|     codes: ['105465640', '46845132', '1645468'], | ||||
|     defaultMoneyArray: [100, 200, 500, 1000, 2000], | ||||
|     customFlag: false, | ||||
|     detail: {} | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * 生命周期函数--监听页面加载 | ||||
|    */ | ||||
|   onLoad(options) { | ||||
|  | ||||
|     const { tenement, code } = options | ||||
|     console.log('options', options) | ||||
|     this.init({ tenement, code }) | ||||
|   }, | ||||
|   async init(options) { | ||||
|     const { code, message, data = {}} = await getMeterDetail(options) | ||||
|     console.log('data', data) | ||||
|     this.setData({ | ||||
|       detail: data | ||||
|     }) | ||||
|   }, | ||||
|  | ||||
|   /** | ||||
|    * 生命周期函数--监听页面初次渲染完成 | ||||
|    */ | ||||
| @@ -38,7 +46,6 @@ Page({ | ||||
|   }, | ||||
|   chooseMoney(e) { | ||||
|     const { money, index } = e.currentTarget.dataset; | ||||
|     console.log('index', index, typeof index) | ||||
|     this.setData({ | ||||
|       money, | ||||
|       moneyIndex: Number(index), | ||||
| @@ -59,19 +66,17 @@ Page({ | ||||
|     }) | ||||
|   }, | ||||
|   onChangeCustomMoney(e) { | ||||
|     console.log('onChangeCustomMoney', e) | ||||
|     const money = e.detail.value; | ||||
|     this.setData({ | ||||
|       money: money, | ||||
|     }) | ||||
|   }, | ||||
|   async recharge() { | ||||
|     const { code, money } = this.data; | ||||
|     const confirmResult = await showModal({ title: "充值确认", content: `确认充值表号为${code}的表计${money}元吗?` }); | ||||
|     const { detail = {}, money } = this.data; | ||||
|     const confirmResult = await showModal({ title: "充值确认", content: `确认充值表号为${detail?.meter?.code}的表计${money}元吗?` }); | ||||
|     if (!confirmResult) { | ||||
|       return; | ||||
|     } | ||||
|     console.log('确认') | ||||
|   }, | ||||
|   /** | ||||
|    * 生命周期函数--监听页面隐藏 | ||||
|   | ||||
| @@ -1,5 +1,10 @@ | ||||
| { | ||||
|   "usingComponents": { | ||||
|     "navigator": "/components/navigator/index" | ||||
|   } | ||||
|     "navigator": "/components/navigator/index", | ||||
|     "van-grid": "@vant/weapp/grid/index", | ||||
|     "van-grid-item": "@vant/weapp/grid-item/index", | ||||
|     "van-row": "@vant/weapp/row/index", | ||||
|     "van-col": "@vant/weapp/col/index" | ||||
|   }, | ||||
|   "navigationBarTitleText": "充值" | ||||
| } | ||||
| @@ -1,42 +1,76 @@ | ||||
| <!--pages/recharge/index.wxml--> | ||||
| <navigator title="充值" /> | ||||
|  | ||||
| <view class="wrapper"> | ||||
| <!-- 账单周期 T13561356146548465815313 创新风华 --> | ||||
| <view style="display: flex;align-items: center;font-size: 24rpx;"> | ||||
|   <view style="margin-right: 20rpx;"> | ||||
|     <view> 电费账单 </view> | ||||
|     <view> 2024年02月 </view> | ||||
|   </view> | ||||
|   <view style="flex: 1;display: flex;"> | ||||
|     <view style="margin-right: 20rpx;">  | ||||
|       <view>商户编号</view> | ||||
|     <view> T00062102047096834 </view> </view> | ||||
|     <view> | ||||
|   <!-- <van-grid column-num="2" center="{{false}}"> | ||||
|     <van-grid-item icon="photo-o" text="文字" use-slot> | ||||
|       <view> | ||||
|       商户名称 | ||||
|         <view class="gridTitle"> 充值表号: </view> | ||||
|         <view class="gridContent"> {{ detail.meter.code }} </view> | ||||
|       </view> | ||||
|     </van-grid-item> | ||||
|     <van-grid-item icon="photo-o" text="文字" use-slot> | ||||
|       <view> | ||||
|       创新风华</view> | ||||
|     </view> | ||||
|   </view> | ||||
| </view> | ||||
|   <!-- <view class="chooseMeter"> | ||||
|     充值表号 | ||||
|     <view class="selectMeter"> | ||||
|       <picker bindchange="onChangeCode" value="{{index}}" range="{{codes}}"> | ||||
|         <view class="picker"> | ||||
|           <view class="input border" wx:if="{{code}}">{{code}}</view> | ||||
|           <view class="input border" style="color: rgb(116, 109, 109)" wx:else>请选择</view> | ||||
|         </view> | ||||
|       </picker> | ||||
|     </view> | ||||
|   </view> | ||||
|         <view class="gridTitle"> 表计地址: </view> | ||||
|         <view class="gridContent"> {{ detail.meter.address }} </view> | ||||
|       </view> | ||||
|     </van-grid-item> | ||||
|     <van-grid-item icon="photo-o" text="文字" use-slot> | ||||
|       <view> | ||||
|         <view class="gridTitle"> 剩余金额: </view> | ||||
|         <view class="gridContent"> {{ detail.money }} </view> | ||||
|       </view> | ||||
|     </van-grid-item> | ||||
|     <van-grid-item icon="photo-o" text="文字" use-slot> | ||||
|       <view> | ||||
|         <view class="gridTitle"> 公司名称: </view> | ||||
|         <view class="gridContent"> {{ detail.tenement.name }} </view> | ||||
|       </view> | ||||
|     </van-grid-item> | ||||
|   </van-grid> --> | ||||
|   <van-row gutter="10"> | ||||
|     <van-col span="12"> | ||||
|       <view class="title">充值表号:</view> | ||||
|       <view class="content">{{ detail.meter.code }}</view> | ||||
|     </van-col> | ||||
|     <van-col span="12"> | ||||
|       <view class="title">表计地址:</view> | ||||
|       <view class="content">{{ detail.meter.address }}</view> | ||||
|     </van-col> | ||||
|    | ||||
|       <van-col span="12"  custom-class="colBottom"> | ||||
|         <view class="title">剩余金额:</view> | ||||
|         <view class="content">{{ detail.money }}</view> | ||||
|       </van-col> | ||||
|       <van-col span="12" custom-class="colBottom"> | ||||
|         <view class="title">公司名称:</view> | ||||
|         <view class="content">{{ detail.tenement.name }}</view> | ||||
|       </van-col> | ||||
|  | ||||
|   </van-row> | ||||
|   <view class="moneyBoxs"> | ||||
|     <view wx:for="{{defaultMoneyArray}}" class="moneyBox border radius12" style="background-color: {{moneyIndex === index ? primaryColor : ''}};" bind:tap="chooseMoney" data-money="{{item}}" data-index="{{index}}"> {{item}} </view> | ||||
|     <view  | ||||
|       wx:for="{{defaultMoneyArray}}"  | ||||
|       class="moneyBox border radius12"  | ||||
|       style="background-color: {{moneyIndex === index ? primaryColor : ''}};"  | ||||
|       wx:key="index"  | ||||
|       bind:tap="chooseMoney"  | ||||
|       data-money="{{item}}"  | ||||
|       data-index="{{index}}" | ||||
|     > {{item}} </view> | ||||
|     <view class="moneyBox border radius12" bind:tap="custom"> 自定义 </view> | ||||
|   </view> | ||||
|     <view class="customInput border radius12" wx:if="{{customFlag}}" > <input type="number" focus placeholder="请输入要充值的金额"	bindinput="onChangeCustomMoney"/> </view> | ||||
|   <view  | ||||
|     class="customInput border radius12"  | ||||
|     wx:if="{{customFlag}}" | ||||
|   >  | ||||
|     <input  | ||||
|       type="number"  | ||||
|       focus  | ||||
|       placeholder="请输入要充值的金额"  | ||||
|       bindinput="onChangeCustomMoney"  | ||||
|     /> | ||||
|   </view> | ||||
|   <view class="operate"> | ||||
|     <button type="primary" bind:tap="recharge" disabled="{{!code || !money}}"> 充值 </button> | ||||
|   </view> --> | ||||
|     <button type="primary" bind:tap="recharge" disabled="{{!money}}"> 充值 </button> | ||||
|   </view> | ||||
| </view> | ||||
| @@ -41,4 +41,22 @@ | ||||
|  | ||||
| .customInput { | ||||
|   padding: 16rpx 24rpx; | ||||
| } | ||||
|  | ||||
| .gridTitle { | ||||
|   margin-bottom: 24rpx; | ||||
| } | ||||
|  | ||||
| .colBottom { | ||||
|   margin-top: 40rpx; | ||||
| } | ||||
|  | ||||
| .title { | ||||
|   font-weight: 600; | ||||
|   font-size: 40rpx; | ||||
|   margin-bottom: 20rpx; | ||||
| } | ||||
|  | ||||
| .content { | ||||
|   font-size: 32rpx; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user