瀏覽代碼

feat:预支付页面优化

huang, kai (Contractor) 2 月之前
父節點
當前提交
7bdc5b0cdc
共有 3 個文件被更改,包括 37 次插入23 次删除
  1. 1 1
      app.json
  2. 32 15
      pages/quantify/quantify.js
  3. 4 7
      pages/quantify/quantify.wxml

+ 1 - 1
app.json

@@ -1,7 +1,7 @@
 {
   "pages": [
-    "pages/scan/scan",
     "pages/quantify/quantify",
+    "pages/scan/scan",
     "pages/moreOrder/moreOrder",
     "pages/TransactionPage/TransactionPage",
     "pages/index/index",

+ 32 - 15
pages/quantify/quantify.js

@@ -1,17 +1,19 @@
-// pages/quantify/quantify.js
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    nozzleId:'',
-    quantify:'元',
-    fastInputs:[10,20,50,100,200,500],
-    type:[
-      { name:'金额',checked:true},
-      { name:'升数',checked:false}
-    ]
+    nozzleId: '',
+    quantify: '元',
+    fastInputs: [10, 20, 50, 100, 200, 500],
+    type: [
+      { name: '金额', checked: true },
+      { name: '升数', checked: false }
+    ],
+    inputValue: '',
+    inputTip: '请输入金额',
+    amount:''
   },
 
   /**
@@ -20,7 +22,7 @@ Page({
   onLoad(options) {
     const id = decodeURIComponent(options.q) // 获取到二维码原始链接内容
     this.setData({
-      nozzleId:id
+      nozzleId: id
     })
     wx.showToast({
       title: id,
@@ -28,6 +30,17 @@ Page({
   },
 
   /**
+   * 处理快速输入金额的点击事件
+   */
+  onFastInputClick(event) {
+    console.log("点击",event)
+    const amount =event.currentTarget.dataset.id;
+    this.setData({
+      inputValue: amount
+    });
+  },
+
+    /**
    * 生命周期函数--监听页面初次渲染完成
    */
   onReady() {
@@ -76,17 +89,21 @@ Page({
 
   },
 
-  /** 当选择定量类型 */
+  /**
+   * 当选择定量类型
+   */
   onTypeChange(event) {
     var type = event.detail.value;
-    if(type == '升数') {
+    if (type == '升数') {
       this.setData({
-        quantify:'升'
-      })
+        quantify: '升',
+        inputTip: '请输入升数'
+      });
     } else {
       this.setData({
-        quantify:'元'
-      })
+        quantify: '元',
+        inputTip: '请输入金额'
+      });
     }
   }
 })

+ 4 - 7
pages/quantify/quantify.wxml

@@ -1,4 +1,3 @@
-
 <view class="quantifyContainer">
   <!-- 提示 -->
   <view class="tip">
@@ -20,8 +19,8 @@
     <view class="inputBox">
       <!-- 输入 -->
       <view class="input">
-        <text>请输入金额</text>
-        <input type="digit" placeholder="0.00{{quantify}}"/>
+        <text>{{inputTip}}</text>
+        <input type="digit" placeholder="0.00{{quantify}}" value="{{inputValue}}{{quantify}}" />
       </view>
 
       <!-- 分割线 -->
@@ -29,17 +28,15 @@
 
       <!-- 快速输入 -->
       <view class="fastInput">
-        <text class="fastItem" wx:for="{{fastInputs}}" wx:key="{{index}}">{{item}}{{quantify}}</text>
+        <text class="fastItem" wx:for="{{fastInputs}}" wx:key="{{index}}" bindtap="onFastInputClick" data-id="{{item}}">{{item}}{{quantify}}</text>
       </view>
 
       <!-- 定量类型选择 -->
       <radio-group class="typeSelect" bindchange="onTypeChange">
-        <radio wx:for="{{type}}" checked="{{item.checked}}"
-        color="#d81e07" value="{{item.name}}">{{item.name}}</radio>
+        <radio wx:for="{{type}}" checked="{{item.checked}}" color="#d81e07" value="{{item.name}}">{{item.name}}</radio>
       </radio-group>
     </view>
   </view>
 
   <text class="anthorization">授权</text>
-
 </view>