123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- <template>
- <s-layout style="margin-top: 40px;">
- <view style="background-color: #fff;">
- <!-- <view class="cu-bar bg-white ">
- <view class="action">
- <text class="cuIcon-titles text-orange"></text> 配送方式
- </view>
- </view> -->
- <!-- <scroll-view scroll-x class="bg-white nav">
- <view class="flex text-center">
- <view class="cu-item flex-sub" :class="TabCur=='1'?'text-orange cur':''" @tap="tabSelect" :data-id="1">
- 配送
- </view>
- <view class="cu-item flex-sub" :class="TabCur=='2'?'text-orange cur':''" @tap="tabSelect" :data-id="2">
- 到店
- </view>
- </view>
- </scroll-view> -->
- <uni-datetime-picker type="datetime" v-model="datetimesingle" placeholder="预计时间" />
- </view>
- <!-- <view style="background-color: #fff;">
- <view class="cu-bar bg-white ">
- <view class="action">
- <text class="cuIcon-titles text-orange"></text> 收货地址
- </view>
- </view>
- <view style="width: 100%;padding:10px;" class="ss-flex">
- <view style="width: 40%;font-size: 20px;">{{ addressList.name }}</view>
- <view style="width: 50%;font-size: 20px;">{{ addressList.phone }}</view>
- </view>
- <view style="width: 100%;padding:10px;">{{ addressList.address }}</view>
- <button style="margin: 20px;" type="primary"
- @tap="sheep.$router.go('/pages/user/address/edit')">修改地址</button>
- </view> -->
- <view style="height: 80vh;">
- <view class="cu-bar bg-white ">
- <view class="action">
- <text class="cuIcon-titles text-orange"></text> 购物车
- </view>
- </view>
- <view style="height: 70vh;overflow-y: auto;background-color: #fff;">
- <view v-for="(i, j) in nowCartList" :key="j" class="minmi" style="width: 100vw;">
- <image class="imgPic" :src="i.url" mode=""></image>
- <view class="rightContainer">
- <view class="foodName">
- {{ i.name }}
- </view>
- <view class="foodPrice">
- <view class="priceflex">
- <text class="zero">¥</text>
- {{ i.priceVisable }}
- </view>
- <view class="shopCar iconfont-themeColor-write" v-show="i.num == 0" @tap="addcart(i)">
- <text class="lg text-white cuIcon-add"></text>
- </view>
- <view class="" v-if="i.num > 0">
- <!-- <text class="lg text-white cuIcon-minus" @tap="addcart(i)" ></text> -->
- <!-- <uni-number-box :min="0" :max="100" :step="1" v-model="i.num" @tap="chengeCart(i)" /> -->
- <text>{{ i.num }}</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <button class="bg-red submit" @click="handleOk()">立即支付</button>
- </view>
- </s-layout>
- </template>
- <script setup>
- import sheep from '@/sheep';
- import { onLaunch, onShow, onError } from '@dcloudio/uni-app';
- import { computed, reactive, ref ,onMounted} from 'vue';
- import goodsApi from '@/sheep/api/restaurant/goods'
- const cart = sheep.$store('cart');
- const TabCur = ref(1)
- const datetimesingle = ref('')
- const nowCartList= computed(() => cart.list)
- const addressList = computed(() => {
- let addressList = sheep.$store('user').addressList
- console.log('restaurant', addressList)
- return addressList
- })
- const updateTime = () => {
- datetimesingle.value= new Date().getTime()
- console.log('updateTime',datetimesingle.value)
- }
- const handleOk= async () =>{
- if(datetimesingle.value ==''){
- sheep.$helper.toast('请选择用餐时间')
- return
- }
- let pamser = {
- name: addressList.value.name,
- phone: addressList.value.phone,
- address: addressList.value.address,
- useTime:datetimesingle.value,
- type: TabCur.value,
- goodsList:nowCartList.value,
- openid :uni.getStorageSync('openid')
-
- }
- const formData = {
- ...pamser
- }
- console.log('pamser',formData)
- await goodsApi.createOrder(formData).then(res => {
- // console.log(res)
- let data = JSON.stringify(res.data)
- console.log("res.data:"+JSON.stringify(res.data))
- console.log("data.appId:"+data.appId)
- pay(res.data)
-
- })
- }
- const pay= (data) =>{
- let appId = data.appId;
- let timeStamp = data.timeStamp;
- let nonceStr = data.nonceStr;
- let packageX = data.packageX;
- let signType = data.signType;
- let paySign = data.paySign;
- console.log(appId, "appId")
- console.log(timeStamp, "timeStamp")
- console.log(nonceStr, "nonceStr")
- console.log(packageX, "package")
- console.log(signType, "signType")
- console.log(paySign, "paySign")
- uni.requestPayment({
- provider: "wxpay",
- timeStamp: timeStamp, // 时间戳(单位:秒)
- nonceStr: nonceStr, // 随机字符串
- package: packageX, // 固定值
- signType: signType,
- paySign: paySign, // 签名,这里用的 MD5/RSA 签名
- success : function (res) {
- console.log("success" + JSON.stringify(res))
- // uni.navigateTo({url: '/pages/order/detail'});
- sheep.$router.go('/pages/order/detail', {
- id:data.orderId,
- });
- sheep.$helper.toast('支付成功')
- },
- fail: function (res) {
- console.log("fail" + JSON.stringify(res))
- sheep.$helper.toast('支付失败')
- // pay(data)
- },
- complete: function (res){
- console.log("调用完成")
- }
- });
- }
- const tabSelect= (e) =>{
- console.log(e.currentTarget.dataset.id)
- TabCur.value = e.currentTarget.dataset.id;
- }
- onMounted(() => {
- updateTime()
- })
- </script>
- <style scoped lang="scss">
- .title{
- width: 99%;
- text-align: left;
- padding-left: 10px;
- border-left: 5px solid red;
- font-size: 18px;
- margin-left: 20px;
- margin-top: 10px;
- font-weight: 800;
- }
- .active {
- font-size: 30upx;
- color: #F9BE3E;
- }
- .active2 {
- font-size: 30upx;
- }
- .min {
- display: flex;
- flex-direction: row;
- justify-content: space-around;
- flex-wrap: wrap;
- // margin: 20px 0;
- background-color: white;
- padding-bottom: 20px;
- }
- .minmi {
- display: flex;
- width: 592upx;
- margin-left: 25upx;
- padding-top: 51upx;
- .imgPic {
- width: 208upx;
- height: 167upx;
- border-radius: 10upx;
- margin-left: 20upx;
- }
- .rightContainer {
- display: flex;
- flex-direction: column;
- height: 167upx;
- box-sizing: border-box;
- justify-content: space-between;
- align-items: flex-start;
- padding-left: 18upx;
- padding-right: 18upx;
- padding-top: 18upx;
- // padding-bottom: 18upx;
- flex: 1;
- .foodName {
- font-weight: 700;
- font-size: 25upx;
- }
- .foodPrice {
- display: flex;
- justify-content: space-between;
- width: 375upx;
- color: #F9BE3E;
- .priceflex {
- display: flex;
- align-items: center;
- .zero {
- font-size: 15upx;
- }
- }
- .shopCar {
- background-color: #F9BE3E;
- border-radius: 45upx;
- width: 112upx;
- height: 45upx;
- font-size: 25upx;
- text-align: center;
- line-height: 46upx;
- }
- }
- }
- }
- .aside-main {
- width: 100%;
- display: flex;
- flex-direction: row;
- justify-content: space-between;
- box-sizing: border-box;
- }
- .scroll-Y1 {
- flex: 1;
- box-sizing: border-box;
- }
- .scroll-Y1 view {
- text-align: center;
- padding-top: 33upx;
- // padding-bottom: 33upx;
- }
- .scroll-Y2 {
- flex: 3;
- box-sizing: border-box;
- // padding-bottom: 170upx;
- }
- .scroll-Y2 view {
- text-align: center;
- /* margin:20upx; */
- }
- .icon {
- width: 50upx;
- height: 50upx;
- margin-top: 10upx;
- }
- .icon1 {
- width: 30upx;
- height: 30upx;
- position: absolute;
- top: 15upx;
- left: 10upx;
- }
- .btn {
- width: 140upx;
- height: 60upx;
- line-height: 60upx;
- margin: 0;
- padding: 0;
- font-size: 30upx;
- }
- .serch {
- height: 60upx;
- flex: 2;
- margin-left: 20upx;
- margin-right: 20upx;
- box-sizing: border-box;
- border: solid 1upx #ccc;
- border-radius: 10upx;
- position: relative;
- }
- .serch input {
- height: 60upx;
- margin-left: 60upx;
- }
- </style>
|