From 5d70c2d38f12437afedc1c978269d29689ff0c2e Mon Sep 17 00:00:00 2001 From: yiming <m13691596795@163.com> Date: 星期四, 28 三月 2024 19:54:52 +0800 Subject: [PATCH] 微信支付 --- pages/home/home.js | 25 +++ pages/cart/index.js | 64 +++++++-- pages/cart/paymentPage/index.js | 5 assets/js/middleGround/api/file.js | 8 + pages/bibliographyList/index.wxml | 18 ++ pages/bibliographyList/index.wxss | 52 ++++++++ assets/js/config.js | 3 pages/bibliographyList/index.json | 5 pages/retrievalPage/index.wxml | 15 - pages/retrievalPage/index.js | 62 ++++----- pages/retrievalPage/index.wxss | 3 pages/bibliographyList/index.js | 91 ++++++++++++-- 12 files changed, 262 insertions(+), 89 deletions(-) diff --git a/assets/js/config.js b/assets/js/config.js index 950f3e7..c3ec65c 100644 --- a/assets/js/config.js +++ b/assets/js/config.js @@ -33,6 +33,7 @@ seminar, reg_tel, reg_telphone, - epubUrl + epubUrl, + appId }; export default config; \ No newline at end of file diff --git a/assets/js/middleGround/api/file.js b/assets/js/middleGround/api/file.js index 918ae65..4339689 100644 --- a/assets/js/middleGround/api/file.js +++ b/assets/js/middleGround/api/file.js @@ -84,6 +84,14 @@ 'md5s': params } }); + }, + // 鍙戦�佷笅杞介偖浠� + sendFileWithEmail(data) { + return request({ + url: '/file/api/ApiSendFileWithEmail', + method: 'post', + data + }) } } diff --git a/pages/bibliographyList/index.js b/pages/bibliographyList/index.js index c02f54b..27743d5 100644 --- a/pages/bibliographyList/index.js +++ b/pages/bibliographyList/index.js @@ -7,6 +7,10 @@ * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { + input: '', + dialogKey: '', + showWithInput: false, + showTextAndTitleWithInput: false, downloadLoadin: false, isMore: null, higherList: [], @@ -20,7 +24,9 @@ navBarHeight: '', start: 1, tabValue: '', - keyword: '' + keyword: '', + Md5: '', + emailError: false, }, /** @@ -39,9 +45,10 @@ barHeight: systInfo.statusBarHeight, }) - let event = - { - detail: { value: "0" } + let event = { + detail: { + value: "0" + } } this.onTabsChange(event) @@ -248,10 +255,8 @@ teacherList: res.datas, teacherTotal: res.total }) - }) wx.stopPullDownRefresh() - }, downloadData(event) { this.setData({ @@ -286,13 +291,11 @@ console.log('涓嬭浇鏂囦欢澶辫触', res); } }); - setTimeout(() => { this.setData({ downloadLoadin: false }); }, 2000); - }, onSearchSubmit: function (e) { const keyword = e.detail.value; @@ -301,7 +304,6 @@ this.higherGet(keyword) this.vocationalGet(keyword) this.teacherGet(keyword) - }, @@ -376,20 +378,81 @@ }, onPullDownRefresh() { - - let keyword = this.data.value - this.setData({ start: 1, - }) - this.higherGet(keyword) this.vocationalGet(keyword) this.teacherGet(keyword) + }, + // 閭鐐瑰嚮 + mailbox(e) { + const key = e.currentTarget.dataset.key; + const item = e.currentTarget.dataset.item; + + + + this.setData({ + [key]: true, + dialogKey: key, + input: '', + Md5: item.datas.freeFile.FileList[0].Md5 + }); + }, + onEmailInput(e) { + const isEmailValid = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(e.detail.value); + this.setData({ + emailError: !isEmailValid, + "input": e.detail.value, + }); + }, + //寮圭獥纭 + onConfirm() { + if (!this.data.emailError && this.data.input) { + const { + dialogKey + } = this.data; + this.setData({ + [dialogKey]: false + }); + + + console.log(this.data.input); + console.log(this.data.Md5); + if (this.data.input) { + let query = { + eMail: this.data.input, + md5s: [this.data.Md5] + } + app.MG.file.sendFileWithEmail(query).then(res => { + console.log(res); + }) + } + } else { + // 鏍¢獙涓嶉�氳繃锛岀粰鍑洪敊璇彁绀� + wx.showToast({ + title: '閭鏍煎紡涓嶆纭�', + icon: 'none', + }); + } + + }, + // 寮圭獥鍙栨秷 + closeDialog() { + const { + dialogKey + } = this.data; + this.setData({ + [dialogKey]: false + }); + console.log(111); + }, + + + }) \ No newline at end of file diff --git a/pages/bibliographyList/index.json b/pages/bibliographyList/index.json index 4a7df72..ff56726 100644 --- a/pages/bibliographyList/index.json +++ b/pages/bibliographyList/index.json @@ -7,7 +7,10 @@ "t-icon": "tdesign-miniprogram/icon/icon", "t-loading": "tdesign-miniprogram/loading/loading", "t-image": "tdesign-miniprogram/image/image", - "t-empty": "tdesign-miniprogram/empty/empty" + "t-empty": "tdesign-miniprogram/empty/empty", + "t-button": "tdesign-miniprogram/button/button", + "t-input": "tdesign-miniprogram/input/input", + "t-dialog": "tdesign-miniprogram/dialog/dialog" }, "navigationStyle": "custom", "enablePullDownRefresh": true, diff --git a/pages/bibliographyList/index.wxml b/pages/bibliographyList/index.wxml index e55f940..94cf918 100644 --- a/pages/bibliographyList/index.wxml +++ b/pages/bibliographyList/index.wxml @@ -39,10 +39,14 @@ </view> <view wx:else class="outsideHigherBox"> - <view class="higherBox" wx:for="{{higherList}}" wx:key="index" wx:for-item="item" wx:for-index="index" bind:tap="downloadData" data-item="{{item}}"> + <view class="higherBox" wx:for="{{higherList}}" wx:key="index" wx:for-item="item" wx:for-index="index"> <view class="outsideHigherImageBox"> - <image class="higherImageBox" src="{{item.icon}}" mode="" /> - <view class="downloadIcon" data-item="{{item}}"> + <view bind:tap="downloadData" data-item="{{item}}"> + + <image class="higherImageBox" src="{{item.icon}}" mode="" /> + </view> + + <view class="downloadIcon" data-item="{{item}}" data-key="showWithInput" bind:tap="mailbox"> <image wx:if="{{determine}}" class="download" src="/static/images/bibliographyList/email-click.png" mode="" /> <image wx:else="" class="downloadshiftin" src="/static/images/bibliographyList/email.png" mode="" /> @@ -112,6 +116,12 @@ <text wx:if="{{isMore == false}}">娌℃湁鏇村浜�</text> </view> </t-tab-panel> - </t-tabs> +</view> +<view class="dialogBox"> + <t-dialog visible="{{showWithInput}}" title="璇疯緭鍏ラ偖绠�" confirm-btn="纭畾" cancel-btn="鍙栨秷" bind:confirm="onConfirm" bind:cancel="closeDialog"> + + <t-input model:value="{{input}}" borderless class="dialog-input" clearable slot="content" placeholder="璇疯緭鍏ラ偖绠卞彿" placeholder-class="placeholder" bindchange="onEmailInput" /> + + </t-dialog> </view> \ No newline at end of file diff --git a/pages/bibliographyList/index.wxss b/pages/bibliographyList/index.wxss index 34c5cc1..2b08ccc 100644 --- a/pages/bibliographyList/index.wxss +++ b/pages/bibliographyList/index.wxss @@ -101,7 +101,7 @@ } /*杈撳叆妗�*/ -.nav_input { +/* .nav_input { border: 1px solid var(--egry-col); border-radius: 40rpx; padding-left: 72rpx; @@ -111,7 +111,7 @@ box-sizing: border-box; line-height: 75rpx; height: 75rpx; -} +} */ .t-tabs__item--active { color: #FF6C00 !important; @@ -170,4 +170,52 @@ align-items: center; margin: 0 auto; margin-top: 250rpx; +} + +.wrapper { + margin-bottom: 32rpx; +} + +.placeholder { + color: rgba(0, 0, 0, 0.26); + line-height: 96rpx; + height: 96rpx !important; + display: flex; + align-items: center; +} + +.dialog-input { + padding-top: 12px; + padding-bottom: 12px; + text-align: left; + margin-top: 32rpx; + border-radius: 8rpx; + background-color: #f3f3f3; + box-sizing: border-box; +} + +.placeholder { + color: rgba(0, 0, 0, 0.4); + line-height: 96rpx; +} + +.dialogBox .t-input__control { + + min-height: 100rpx; +} + +.t-button--text { + color: #000 !important; + +} + +.t-button--text.t-button--primary { + color: var(--td-button-primary-text-color, var(--td-brand-color, var(--td-primary-color-7, #0052d9))) !important; + background: none; +} + +.t-input__control { + /* border: 1rpx #000 solid; */ + background-color: #F9F9F9; + width: 100%; } \ No newline at end of file diff --git a/pages/cart/index.js b/pages/cart/index.js index 546e1c1..6307aa3 100644 --- a/pages/cart/index.js +++ b/pages/cart/index.js @@ -1,9 +1,14 @@ const app = getApp(); // import { getPublicImage } from '@/assets/js/middleGround/tool.js' -import { getPublicImage } from '../../assets/js/middleGround/tool'; +import { + loginInfo +} from '../../assets/js/login'; +import { + getPublicImage +} from '../../assets/js/middleGround/tool'; import Toast from 'tdesign-miniprogram/toast/index'; -import { loginInfo } from '../../assets/js/login'; + Page({ data: { onDisabled: false, @@ -35,7 +40,11 @@ }) } this.shoppingCartGet(); - this.setData({ totalPrice: 0.00, selectedCount: 0, checkAll: false, }) + this.setData({ + totalPrice: 0.00, + selectedCount: 0, + checkAll: false, + }) }, @@ -45,7 +54,10 @@ ids: [item.id] }).then(res => { this.shoppingCartGet(); - wx.showToast({ title: '鍒犻櫎鍥句功鎴愬姛', icon: 'none' }); + wx.showToast({ + title: '鍒犻櫎鍥句功鎴愬姛', + icon: 'none' + }); }); }, @@ -108,7 +120,9 @@ }, HandelItemChange(e) { - const { item } = e.target.dataset; + const { + item + } = e.target.dataset; const items = this.data.shoppingCartData items.map(eitem => { if (eitem.id == item.id) { @@ -147,7 +161,6 @@ goPaymentPage() { - // 棣栭〉娴嬭瘯鐧诲綍鍔熻兘锛屽悗缁敞閲� // 妫�鏌ョ櫥褰曠姸鎬� const token = wx.getStorageSync(app.config.tokenKey) @@ -155,8 +168,6 @@ loginInfo(app, (data) => { // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� if (data) { - - const selectedItems = this.data.shoppingCartData.filter(item => item.checked); // console.log(selectedItems, 789); const selectedIds = selectedItems.map(item => item.id); @@ -166,9 +177,6 @@ linkIds: selectedIds } app.MG.store.shoppingCartCreateOrder(data).then(res => { - // console.log(res, 456); - - const url = '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber wx.navigateTo({ url @@ -188,11 +196,30 @@ } }) } else { - // 濡傛灉鏄涓�娆$櫥褰曪紝浼氳烦杞嚦缁戝畾鐢ㄦ埛淇℃伅椤甸潰锛屽~鍐欏畬鐢ㄦ埛淇℃伅鍚庤繘琛岀櫥褰曞苟鍌ㄥ瓨token鍜岀敤鎴蜂俊鎭紝缁撴潫鍚庤烦杞洖褰撳墠椤甸潰锛堟惡甯﹂〉闈㈠弬鏁帮級 + const selectedItems = this.data.shoppingCartData.filter(item => item.checked); + // console.log(selectedItems, 789); + const selectedIds = selectedItems.map(item => item.id); + console.log('閫変腑鐨勫晢鍝� id:', selectedIds); + if (selectedIds.length) { + let data = { + linkIds: selectedIds + } + app.MG.store.shoppingCartCreateOrder(data).then(res => { + const url = '/pages/cart/paymentPage/index?orderNumber=' + res.orderNumber + wx.navigateTo({ + url + }); + }) + } else { + Toast({ + context: this, + selector: '#t-toast', + message: '璇烽�夋嫨鍟嗗搧', + theme: 'warning', + direction: 'column', + }); + } } - - - @@ -227,10 +254,13 @@ onPullDownRefresh() { this.setData({ - start: 1 + start: 1, + checkAll: false, + selectedCount: 0, + totalPrice: 0.00, }) console.log(978); this.shoppingCartGet() }, -}); +}); \ No newline at end of file diff --git a/pages/cart/paymentPage/index.js b/pages/cart/paymentPage/index.js index 37b34e9..34623b1 100644 --- a/pages/cart/paymentPage/index.js +++ b/pages/cart/paymentPage/index.js @@ -1,6 +1,8 @@ // pages/cart/paymentPage/index.js const app = getApp() -import { getPublicImage } from '../../../assets/js/middleGround/tool'; +import { + getPublicImage +} from '../../../assets/js/middleGround/tool'; import drawQrcode from './js/weapp.qrcode' Page({ @@ -134,6 +136,7 @@ if (res.orderNumber) { let resOrderNum = { orderNum: res.orderNumber, + platform: "WeChatAppCustom" }; console.log(resOrderNum, 'resOrderNum'); // 鐢ㄦ埛鏈粦瀹氬井淇� 鎶�500 diff --git a/pages/home/home.js b/pages/home/home.js index fcd8dad..add28de 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -523,8 +523,27 @@ }) }, onRetrievalPage() { - wx.navigateTo({ - url: '/pages/retrievalPage/index?searchVal=' + this.data.searchVal - }) + + // 棣栭〉娴嬭瘯鐧诲綍鍔熻兘锛屽悗缁敞閲� + // 妫�鏌ョ櫥褰曠姸鎬� + const token = wx.getStorageSync(app.config.tokenKey) + if (!token) { + loginInfo(app, (data) => { + // 濡傛灉涓嶆槸绗竴娆$櫥褰曪紝浼氭墽琛屽洖璋� + if (data) { + wx.navigateTo({ + url: '/pages/retrievalPage/index?searchVal=' + this.data.searchVal + }) + } else { + // 鍑虹幇閿欒锛岃繑鍥瀎alse + } + }) + } else { + wx.navigateTo({ + url: '/pages/retrievalPage/index?searchVal=' + this.data.searchVal + }) + } + + }, }); \ No newline at end of file diff --git a/pages/retrievalPage/index.js b/pages/retrievalPage/index.js index 663142c..bd94d94 100644 --- a/pages/retrievalPage/index.js +++ b/pages/retrievalPage/index.js @@ -1,7 +1,9 @@ // pages/retrievalPage/index.js import request from '../../assets/request/index' -import { handleQueryResourceListData } from '../../assets/js/middleGround/tool' +import { + handleQueryResourceListData +} from '../../assets/js/middleGround/tool' const app = getApp() Page({ @@ -14,17 +16,17 @@ navBarHeight: '', barHeight: '', searchVal: '', - bookData: [], //鍥句功 + bookData: [], //鍥句功 bookTotal: 0, - courseData: [], //璇剧▼ + courseData: [], //璇剧▼ courseTotal: 0, - digitalTextbooksData: [], //鏁板瓧鏁欐潗 + digitalTextbooksData: [], //鏁板瓧鏁欐潗 digitalTextbooksTotal: 0, seminarData: [], //涓撻鐮旇 seminarTotal: 0, - biblioClassificationData: [],//涔﹀睍 + biblioClassificationData: [], //涔﹀睍 biblioClassificationTotal: 0, - bookFairData: [],//涔︾洰 + bookFairData: [], //涔︾洰 bookFairTotal: 0, pageCount: { page: 1, @@ -37,6 +39,8 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 */ onLoad(options) { + + console.log(app.config.appId); const systInfo = wx.getSystemInfoSync(); const menu = wx.getMenuButtonBoundingClientRect(); // 鑳跺泭淇℃伅 const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 瀵艰埅鏍忛珮搴� @@ -195,7 +199,7 @@ let queryBook = { AccessControl: { Path: '*', - StoreRefCode: 'defaultGoodsStore27', + StoreRefCode: `defaultGoodsStore${app.config.appId}`, Type: '*', LinkType: '' }, @@ -203,11 +207,9 @@ Start: 0, Size: this.data.pageCount.page * 9, }, - SortQuery: [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], @@ -248,11 +250,9 @@ Start: 0, Size: this.data.pageCount.page * 4 }, - SortQuery: [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], @@ -292,11 +292,9 @@ Start: 0, Size: this.data.pageCount.page * 9, }, - SortQuery: [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], @@ -337,11 +335,9 @@ Start: 0, Size: this.data.pageCount.page * 6, }, - SortQuery: [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], @@ -381,11 +377,9 @@ Start: 0, Size: this.data.pageCount.page * 10 }, - SortQuery: [ - { - LinkOrder: 'Desc' - } - ], + SortQuery: [{ + LinkOrder: 'Desc' + }], CreateDate: [], Description: [], Name: [], @@ -600,8 +594,8 @@ console.log("涓嬫媺鍒锋柊..."); }, /** - * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� - */ + * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁� + */ onReachBottom(e) { if (this.data.tabValue == 0) { console.log(0); diff --git a/pages/retrievalPage/index.wxml b/pages/retrievalPage/index.wxml index 11a118d..228ef28 100644 --- a/pages/retrievalPage/index.wxml +++ b/pages/retrievalPage/index.wxml @@ -19,18 +19,14 @@ <!--pages/retrievalPage/index.wxml--> - - - - <t-tabs class="tabsBox" defaultValue="{{0}}" bind:change="onTabsChange" bind:click="onTabsClick" t-class="custom-tabs" t-class-content="custom-panel"> +<view class="tabsBox" > + <!-- sticky="true" --> + <t-tabs defaultValue="{{0}}" bind:change="onTabsChange" bind:click="onTabsClick" t-class="custom-tabs" t-class-content="custom-panel" sticky="true"> <t-tab-panel label="鍥句功({{bookTotal}})" value="0"> <view wx:if="{{bookData.length <= 0}}" class="noDataBox"> <t-empty icon="folder-open" description="鏆傛棤鏁版嵁" /> </view> <view class="bookDataBox"> - - - <view class="bookDataForBox" wx:for="{{bookData}}" wx:key="index" wx:for-item="item" wx:for-index="index" data-item="{{item}}" bind:tap="onBook"> <view class="imageBox"> <image src="{{item.icon}}" mode="aspectFill" /> @@ -41,13 +37,10 @@ <view class="bookDataAuthor">{{item.author}}</view> </view> </view> - - <view wx:if="{{bookData.length != 0}}" class="bottom-box"> <t-loading theme="circular" size="40rpx" class="wrapper" wx:if="{{isMore == true}}" /> <text wx:if="{{isMore == false}}">娌℃湁鏇村浜�</text> </view> - </t-tab-panel> <t-tab-panel label="璇剧▼({{courseTotal}})" value="1"> <view wx:if="{{courseData.length <= 0}}" class="noDataBox"> @@ -202,4 +195,6 @@ </t-tab-panel> </t-tabs> +</view> + </view> \ No newline at end of file diff --git a/pages/retrievalPage/index.wxss b/pages/retrievalPage/index.wxss index 77b0c91..d036de1 100644 --- a/pages/retrievalPage/index.wxss +++ b/pages/retrievalPage/index.wxss @@ -252,14 +252,13 @@ position: fixed; top: 0px; background-color: #fff; - height: 150px; + height: 120px; z-index: 999; } .tabsBox { margin-top: 300rpx; } - -- Gitblit v1.9.1