Browse Source

feat:1、登录页换为蓝色;2、预下单页面限制定量值;3、预下单快捷键点击高亮

Zhenghanjv 8 months ago
parent
commit
1e1750355d

+ 1 - 1
images/v2_sony48.svg

@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="214.26" height="200" class="icon" viewBox="0 0 1097 1024"><path fill="#0e932e" d="M665.01 74.24c37.53 7.02 35.84 49.96 35.84 49.96l1.69 746.05 35.62 21.43 3.58 26.92 46.52 8.78 4.68 35.7H69.5l4.82-35.63 46.38-8.92 3.43-26.85 35.77-21.43 1.76-746.05s-1.76-42.94 35.69-49.96H665zm152.36 177.23v509.65l-.66.44c-4.6 3.3-34.45 24.36-105.32 80.46v-90.7l42.57-31.16-.37-458.9 63.78-9.87v.08zm-208.6-63.13H253.59v374.93h355.18V188.34zM343.33 326.51v87.33h-40.08v-87.4h40.08zm71.83 0v87.33h-40.08v-87.4h40.08zm73.36 0v87.33h-39.86v-87.4h39.86zm70.58 0v87.33h-40.08v-87.4h40.08zm326-288.7L906.4 62.1l128.87-18.95s41.62-3.58 58.23 37.9l-16.9 21.28s-14.63-27.94-33.2-27.43c-18.66.51-115.57 24.35-115.57 24.35l-35.11 95.9-47.91 40.74-102.4 16.67-12.8-3.36-.73-67.51a76 76 0 0 0-.95-15.22l157.1-128.66z"/></svg>
+<svg t="1745474771185" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2099" id="mx_n_1745474771186" width="200" height="200"><path d="M941.449846 172.110769l-101.297231-99.328a46.552615 46.552615 0 0 0-66.048 0 45.449846 45.449846 0 0 0 0 65.339077l65.61477 64.905846-48.443077 50.097231a41.275077 41.275077 0 0 0 0 57.934769 39.739077 39.739077 0 0 0 28.632615 12.209231h54.587077v424.723692a28.632615 28.632615 0 0 1-57.225846 0v-263.876923a123.392 123.392 0 0 0-124.179692-122.840615h-28.475077V134.774154a75.815385 75.815385 0 0 0-76.169847-75.382154H187.588923a75.776 75.776 0 0 0-76.169846 75.382154v736.177231h-9.728a47.064615 47.064615 0 1 0 0 94.089846h572.455385a47.064615 47.064615 0 1 0 0-94.089846h-9.531077V455.68h28.632615a28.435692 28.435692 0 0 1 28.632615 28.317538V748.307692a124.179692 124.179692 0 0 0 248.359385 0V240.246154a95.310769 95.310769 0 0 0-28.632615-67.938462z m-372.105846 223.035077a41.314462 41.314462 0 0 1-41.826462 41.393231H248.792615a41.314462 41.314462 0 0 1-41.826461-41.393231V195.190154a41.314462 41.314462 0 0 1 41.826461-41.393231h278.724923a41.314462 41.314462 0 0 1 41.826462 41.393231v199.955692z m0 0" fill="#0d7ee7" p-id="2100"></path></svg>

+ 1 - 1
js/api.js

@@ -15,7 +15,7 @@ function request(path, method = 'GET', data = null) {
     var url = api_root + path;
     var nonce = generateRandomString();
     const timestamp = Date.now();
-    console.log('data :' + data);
+    console.log('data :' + JSON.stringify(data));
     let jsonString = (data != null && method != 'GET') ? JSON.stringify(data) : '';
     console.log('request :' + jsonString);
     var stringToSign = "sign_method=" + sign_method +

+ 1 - 1
pages/login/login.wxml

@@ -1,6 +1,6 @@
 <view class="container">
   <view class="image-container">
-    <image src="/images/v2_sony48.svg" mode="widthFix" class="auto-image" style="position: relative; left: -16rpx; top: -135rpx"></image>
+    <image src="/images/v2_sony48.svg" mode="widthFix" class="auto-image" style="position: relative; left: -16rpx; top: -135rpx;"></image>
   </view>
   <view class="action-text" style="position: relative; left: 0rpx; top: -110rpx">立码加油</view>
   <button class="auth-button" open-type="getPhoneNumber" style="width: 547rpx; height: 94rpx; display: block; box-sizing: border-box; left: 0rpx; top: 0rpx"  bindtap="handleAuthLogin" bindgetphonenumber="handleAuthLogin">一键授权登录</button>

+ 3 - 3
pages/login/login.wxss

@@ -35,11 +35,11 @@
   font-size: 18px;
   font-weight: bold;
   margin-bottom: 20px;
-  color: #07c160;
+  color: #0d7ee7;
 }
 
 .auth-button {
-  background-color: #07c160;
+  background-color: #0d7ee7;
   color: white;
   font-size: 18px;
   padding: 8px 20px; /* 调整内边距,降低高度 */
@@ -55,6 +55,6 @@
 }
 
 .link {
-  color: #07c160;
+  color: #0d7ee7;
   text-decoration: underline;
 }

+ 42 - 17
pages/quantify/quantify.js

@@ -14,6 +14,7 @@ Page({
     nozzleInfo: null,
     quantify: '元',
     fastInputs: [10, 20, 50, 100, 200, 500],
+    selectIndex:-1,
     type: [{
       name: '金额',
       checked: true
@@ -23,7 +24,7 @@ Page({
       checked: false
     }
     ],
-    inputValue: '',
+    inputValue: '0.00',
     inputTip: '请输入金额',
     amount: '',
     latitude: 0, //用户当前经度
@@ -113,9 +114,24 @@ Page({
   /** 输入框监听 */
   onInputChange(event) {
     console.log("输入框变化", event)
-    this.setData({
-      inputValue: event.detail.value
-    })
+    let value = event.detail.value;
+    
+    // 1. 过滤非法字符(只允许数字和小数点)
+    value = value.replace(/[^\d.]/g, "");
+
+    // 2. 限制小数点只能出现一次
+    const dotIndex = value.indexOf(".");
+    if (dotIndex !== -1) {
+      value = value.substring(0, dotIndex + 1) + value.substring(dotIndex).replace(/\./g, "");
+    }
+
+    // 3. 限制小数点后最多两位
+    if (dotIndex !== -1 && value.length > dotIndex + 3) {
+      value = value.substring(0, dotIndex + 3);
+    }
+
+    // 4. 更新输入框值
+    this.setData({ inputValue: value });
   },
 
   /**
@@ -123,9 +139,11 @@ Page({
    */
   onFastInputClick(event) {
     console.log("点击", event)
-    const amount = event.currentTarget.dataset.id;
+    const value = event.currentTarget.dataset.id;
+    const index = event.currentTarget.dataset.index;
     this.setData({
-      inputValue: amount
+      inputValue: value,
+      selectIndex:index
     });
   },
 
@@ -137,13 +155,13 @@ Page({
   
     console.log('进入 toAuthorization 方法');
     console.log(this.data)
-    const distance = utils.haversine(this.data.stationLatitude,this.data.stationLongitude,this.data.latitude,this.data.longitude);
-    if(distance > 500) {
-      wx.showToast({
-        title: '您不在油站范围内,请到油站时进行下单',
-      })
-      return
-    }
+    // const distance = utils.haversine(this.data.stationLatitude,this.data.stationLongitude,this.data.latitude,this.data.longitude);
+    // if(distance > 500) {
+    //   wx.showToast({
+    //     title: '您不在油站范围内,请到油站时进行下单',
+    //   })
+    //   return
+    // }
     this.createOrder();
   },
 
@@ -159,11 +177,18 @@ Page({
       return;
     }
 
-    const value = this.data.inputValue;
-    console.log("要授权的油枪信息", nozzle, value)
-    if (value <= 0) {
+    const value = parseFloat(this.data.inputValue);
+    console.log("要授权的油枪信息", nozzle, value);
+    if (this.data.quantify == '元' && (value < 2.00 || value > 9900.00)) {
+      wx.showToast({
+        title: '金额须在2~9900之间',
+      });
+      return;
+    }
+    const price = parseFloat(nozzle.productPrice);
+    if (this.data.quantify == '升' && (value < 1.00 || (value * price) > 9900.00)) {
       wx.showToast({
-        title: '定量值非法',
+        title: '升数不合法',
       });
       return;
     }

+ 1 - 1
pages/quantify/quantify.wxml

@@ -29,7 +29,7 @@
 
       <!-- 快速输入 -->
       <view class="fastInput">
-        <text hover-class="fast-item-hover" class="fastItem" wx:for="{{fastInputs}}" wx:key="index" bindtap="onFastInputClick" data-id="{{item}}">{{item}}{{quantify}}</text>
+        <text hover-class="fast-item-hover" class="{{index != selectIndex ? 'fastItem' : 'fastItemClick'}}" wx:for="{{fastInputs}}" wx:key="index" bindtap="onFastInputClick" data-id="{{item}}" data-index="{{index}}">{{item}}{{quantify}}</text>
       </view>
 
       <!-- 定量类型选择 -->

+ 12 - 0
pages/quantify/quantify.wxss

@@ -102,6 +102,18 @@
   line-height: 100rpx;
   color: #acacac;
 }
+.fastItemClick{
+  flex:1 1 25%;
+  box-sizing: border-box;
+  text-align: center;
+  border: #f2f2f2 solid 2rpx;
+  background-color: #0d7ee7;
+  border-radius: 30rpx;
+  margin: 1%;
+  height: 100rpx;
+  line-height: 100rpx;
+  color: #ffffff;
+}
 
 .typeSelect{
   display: flex;