index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. <template>
  2. <div class="mianBox">
  3. <van-row class="contentBox">
  4. <van-row>
  5. <van-col span="24" class="logo"><van-image width="75" height="75" :src="require('../img/logo.png')" /></van-col>
  6. <van-col span="24" class="introduce">中国东信智慧园区平台</van-col>
  7. <van-col span="24" class="money">{{data.money}}</van-col>
  8. <van-col span="24" class="order_money">订单金额(元)</van-col>
  9. </van-row>
  10. <!-- <van-row class="order_wrap">
  11. <van-row>
  12. <van-col span="8" class="left">用途</van-col>
  13. <van-col span="16" class="right">充值</van-col>
  14. </van-row>
  15. <van-row>
  16. <van-col span="8" class="left">收款单位</van-col>
  17. <van-col span="16"class="right">中国东信智慧园区平台</van-col>
  18. </van-row>
  19. <van-row>
  20. <van-col span="8" class="left">订单编号</van-col>
  21. <van-col span="16" class="right">12345678910123124565</van-col>
  22. </van-row>
  23. <van-row>
  24. <van-col span="8" class="left">订单时间</van-col>
  25. <van-col span="16" class="right">2021-09-27 15:00:00</van-col>
  26. </van-row>
  27. </van-row> -->
  28. <div class="pay_wrap">
  29. <van-button class="pay" color="#F22E3C" @tap="pay">支付</van-button>
  30. <button class="pay" open-type="launchApp" app-parameter="appData" @error="launchAppError" v-if="data.userId">返回APP</button>
  31. </div>
  32. <van-toast id="van-toast" />
  33. <!-- <van-overlay :show="show" @click="show = false" /> -->
  34. </van-row>
  35. </div>
  36. </template>
  37. <script>
  38. import Toast from '../../wxcomponents/vant/weapp/dist/toast/toast';
  39. import { requestPost, requestGet } from '@/utils/user.js';
  40. export default {
  41. data() {
  42. return {
  43. data:{
  44. money:undefined,
  45. openid:null,
  46. app:false,
  47. },
  48. appData:{
  49. errCOde:0,
  50. errStr:null,
  51. extMsg:"未支付",
  52. extraData:"未支付",
  53. openid:null,
  54. transaction:null,
  55. type:"WXLaunchMiniProgramReq.Resp"
  56. }
  57. }
  58. },
  59. onLoad(options) {
  60. //console.log(options)
  61. let _this = this
  62. const data = JSON.parse(options.params)
  63. _this.data = data
  64. uni.getStorage({
  65. key: 'openid',
  66. success: function (res) {
  67. _this.appData.openid = _this.data.openid
  68. if(data.scene){
  69. if(data.scene == "3"){
  70. //console.log("app进入 -->支付页")
  71. _this.data={
  72. money:data.money,
  73. channelId:data.channelId,
  74. userId:data.userId,
  75. scene:data.scene,
  76. openid:res.data,
  77. app:false,
  78. }
  79. }
  80. }else{
  81. //console.log("微信小程序历史记录进入 -->支付页")
  82. _this.data={
  83. money:data.money,
  84. scene:'2',
  85. channelId:'',
  86. userId:null,
  87. openid:data.openid,
  88. app:false,
  89. }
  90. }
  91. _this.data.app = false
  92. _this.pay()
  93. },
  94. fail: function (res) {
  95. },
  96. });
  97. },
  98. methods: {
  99. pay(){
  100. let _this = this
  101. if(_this.data.openid && _this.data.openid != 'null' ){
  102. // Toast(1,_this.data.money)
  103. // uni.redirectTo({
  104. // url: `../over/index?type=游客`
  105. // });
  106. if(_this.data.userId){//app用户充值
  107. //console.log("app用户充值")
  108. requestGet("dxtop/staff/one",
  109. {
  110. "id":_this.data.userId,
  111. },
  112. ).then(res =>{
  113. if(res[1].data.data){
  114. requestPost("dxtop/order/callUnifiedPay",
  115. {
  116. "money": _this.data.money,
  117. "topPayType": "W06",
  118. "payType": "2",
  119. "channelId":_this.data.channelId,
  120. "userId":res[1].data.data.sid,
  121. "scene":_this.data.scene,
  122. "openId":_this.data.openid,
  123. }
  124. ).then(res => {
  125. if(res[1].data?.status == "ERROR"){
  126. if(res[1].data?.code == 500){
  127. if(res[1].data.msg == "acct参数错误"){
  128. Toast("华为、Android10系统,需要开启微信的“浮窗”和“允许在其他上层应用上打开”这两个权限")
  129. }else{
  130. Toast(res[1].data.msg)
  131. }
  132. }else{
  133. Toast(res[1].data.msg)
  134. }
  135. }else{
  136. if(res[1].data){
  137. let data = JSON.parse(res[1].data.data)
  138. uni.requestPayment({
  139. timeStamp: data.timeStamp,
  140. nonceStr: data.nonceStr,
  141. package: data.package,
  142. signType: data.signType,
  143. paySign: data.paySign,
  144. success: function (res) {
  145. //console.log('success:' + JSON.stringify(res));
  146. uni.redirectTo({
  147. url: `../over/index`
  148. });
  149. },
  150. fail: function (err) {
  151. //console.log('fail:' + JSON.stringify(err));
  152. }
  153. });
  154. }
  155. }
  156. }).catch(err =>{
  157. })
  158. }else{
  159. Toast("该用户未暂未录入充值系统...")
  160. }
  161. })
  162. }else{
  163. Toast("请使用'中国东信'APP途径进行充值")
  164. // requestPost("dxtop/order/callUnifiedPay",
  165. // {
  166. // "money": _this.data.money,
  167. // "topPayType": "W06",
  168. // "payType": "2",
  169. // "channelName":"小程序游客充值",
  170. // "scene":2,
  171. // "openId":_this.data.openid,
  172. // }
  173. // ).then(res => {
  174. // if(res[1].data.code == 500){
  175. // Toast(res[1].data.msg)
  176. // }else{
  177. // if(res[1].data){
  178. // let data = JSON.parse(res[1].data.data)
  179. // uni.requestPayment({
  180. // timeStamp: data.timeStamp,
  181. // nonceStr: data.nonceStr,
  182. // package: data.package,
  183. // signType: data.signType,
  184. // paySign: data.paySign,
  185. // success: function (res) {
  186. // console.log('success:' + JSON.stringify(res));
  187. // uni.redirectTo({
  188. // url: `../over/index?type=游客`
  189. // });
  190. // },
  191. // fail: function (err) {
  192. // console.log('fail:' + JSON.stringify(err));
  193. // }
  194. // });
  195. // }
  196. // }
  197. // })
  198. }
  199. // else if(this.data.channelId){//"后台扫码充值"
  200. // console.log("后台扫码充值",this.data.channelId)
  201. // requestPost("dxtop/order/callUnifiedPay",
  202. // {
  203. // "money": this.data.money,
  204. // "topPayType": "W06",
  205. // "payType": "2",
  206. // "channelId":this.data.channelId,
  207. // "userId":'',
  208. // "scene":2,
  209. // "openId":this.data.openid,
  210. // }
  211. // ).then(res => {
  212. // console.log(res,121212)
  213. // if(res[1].data){
  214. // let data = JSON.parse(res[1].data.msg)
  215. // uni.requestPayment({
  216. // timeStamp: data.timeStamp,
  217. // nonceStr: data.nonceStr,
  218. // package: data.package,
  219. // signType: data.signType,
  220. // paySign: data.paySign,
  221. // success: function (res) {
  222. // console.log('success:' + JSON.stringify(res));
  223. // },
  224. // fail: function (err) {
  225. // // Toast({
  226. // // message:JSON.stringify(err),
  227. // // overlay:true,
  228. // // });
  229. // console.log('fail:' + JSON.stringify(err));
  230. // }
  231. // });
  232. // }
  233. // })
  234. // }else{//历史记录充值
  235. // // Toast("小程序历史记录进入充值暂未开放...")
  236. // // return false
  237. // console.log("历史记录充值")
  238. // requestPost("dxtop/order/callUnifiedPay",
  239. // {
  240. // "money": this.data.money,
  241. // "topPayType": "W06",
  242. // "payType": "2",
  243. // "channelId":56,
  244. // "userId":'',
  245. // "scene":2,
  246. // "openId":this.data.openid,
  247. // }
  248. // ).then(res => {
  249. // if(res[1].data){
  250. // let data = JSON.parse(res[1].data.msg)
  251. // uni.requestPayment({
  252. // timeStamp: data.timeStamp,
  253. // nonceStr: data.nonceStr,
  254. // package: data.package,
  255. // signType: data.signType,
  256. // paySign: data.paySign,
  257. // success: function (res) {
  258. // console.log('success:' + JSON.stringify(res));
  259. // },
  260. // fail: function (err) {
  261. // // Toast({
  262. // // message:JSON.stringify(err),
  263. // // overlay:true,
  264. // // });
  265. // console.log('fail:' + JSON.stringify(err));
  266. // }
  267. // });
  268. // }
  269. // })
  270. // }
  271. }else{
  272. //console.log("去授权页",JSON.stringify(_this.data))
  273. uni.redirectTo({
  274. url: `../login/index?params=${JSON.stringify(this.data)}`
  275. });
  276. }
  277. }
  278. },
  279. onShow(options){
  280. }
  281. }
  282. </script>
  283. <style lang="scss" scoped>
  284. .mianBox{
  285. height: 100%;
  286. width: 100%;
  287. color: #000;
  288. box-sizing: border-box;
  289. background-color: #F2F6FC;
  290. position: fixed;
  291. .contentBox{
  292. width: 100%;
  293. height: auto;
  294. padding: 15px 20px;
  295. box-sizing: border-box;
  296. overflow: hidden;
  297. .logo{
  298. /deep/ .van-image{
  299. margin:0 auto;
  300. display: block;
  301. }
  302. }
  303. .introduce{
  304. text-align: center;
  305. color: #000;
  306. display: block;
  307. /deep/ .van-col{
  308. font-size: 20;
  309. margin-top:20px;
  310. letter-spacing: 2px;
  311. }
  312. }
  313. .money{
  314. text-align: center;
  315. color: #000;
  316. /deep/ .van-col{
  317. font-size: 30px;
  318. margin-top: 10px;
  319. font-weight: 700;
  320. }
  321. }
  322. .order_money{
  323. text-align: center;
  324. color: #ccc;
  325. display: block;
  326. /deep/ .van-col{
  327. font-size: 20;
  328. margin-top:10px;
  329. letter-spacing: 2px;
  330. }
  331. }
  332. /deep/ .van-button{
  333. border-radius: 6px;
  334. width: 100% !important;
  335. margin-top:25px;
  336. letter-spacing: 2px;
  337. font-size: 18px;
  338. height: 50px;
  339. }
  340. .order_wrap{
  341. width:95%;
  342. padding:10px 20px 20px 20px;
  343. box-sizing: border-box;
  344. width:95%;
  345. margin:20px 2.5%;
  346. background-color: #fff;
  347. border-radius: 6px;
  348. box-shadow: 0 2px 12px 0 #ccc;
  349. display: block;
  350. /deep/ .van-col{
  351. font-size: 16px;
  352. color:#ccc;
  353. margin-top:10px;
  354. display: block;
  355. }
  356. /deep/ .left{
  357. text-align: left;
  358. }
  359. /deep/ .right{
  360. text-align: right;
  361. }
  362. }
  363. .pay_wrap{
  364. width:95%;
  365. margin:70px 2.5% 0;
  366. .pay{
  367. height: 50px;
  368. font-size: 18px;
  369. border-radius: 10px;
  370. margin-top:40px;
  371. }
  372. }
  373. }
  374. }
  375. .pay{
  376. background:#F22E3C;
  377. color:#fff;
  378. }
  379. </style>