dever 4 anos atrás
pai
commit
31ef505026
4 arquivos alterados com 43 adições e 6 exclusões
  1. 1 1
      lib/dever/config.js
  2. 31 0
      lib/dever/index.js
  3. 10 4
      pages/dream/buy.vue
  4. 1 1
      pages/dream/index.vue

+ 1 - 1
lib/dever/config.js

@@ -12,7 +12,7 @@ const request = {
 	//	服务器接口地址
 
 	host: "http://192.168.2.70/dreamland/",
-	//host: "http://192.168.3.66/dreamland/",
+	host: "http://192.168.3.66/dreamland/",
 	
 	//	请求的参数	
 	data: {},

+ 31 - 0
lib/dever/index.js

@@ -1149,6 +1149,37 @@ var dever = {
 	  })
 	},
 	
+	//拉起支付
+	pay : function(result, location, error) {
+		var self = this;
+		if (!error) {
+			if (location.indexOf('?') == -1) {
+				var fix = '?';
+			} else {
+				var fix = '&';
+			}
+			location = location + fix + 'order_id=' + result.order_id;
+		}
+		
+		if (result.type == 'test') {
+			self.location(location, 'to');
+		} else if (self.source == 'h5') {
+			uni.hideLoading();
+			uni.showLoading({title: '跳转中', mask: true});
+			self.html(result.order);
+		} else if (self.source == 'app') {
+			self.appPayment(result.type, result.order, function() {
+				self.location(location, 'to');
+			}, function() {
+				if (!error) {
+					self.location(location + '&error=1', 'to');
+				} else {
+					self.alert(error);
+				}
+			});
+		}
+	},
+	
 	//app支付
 	appPayment : function(type, order, callback, errorCallback) {
 		uni.requestPayment({

+ 10 - 4
pages/dream/buy.vue

@@ -47,7 +47,9 @@ export default {
 	props: {
 		id : 0,
 		bgcolor : '',
-		color : '',
+		color : '',
+		code : '',
+		name : '',
 	},
 	data() {
 		return {
@@ -79,9 +81,13 @@ export default {
 		buyAct : function() {
 			var self = this;
 			var data = {};
-			data.buy_id = this.fetch.buy[this.index].id;
-			this.Dever.post('app/user/?l=pay.ticket', data, function(t) {
-				console.info(t);
+			data.buy_id = this.fetch.buy[this.index].id;
+			var location = 'dream/view?code='+this.code + '&name=' + this.name;
+			data.refer = this.Dever.host + '/' + location;
+
+			this.Dever.post('app/user/?l=pay.ticket', data, function(t) {
+				console.info(t);
+				self.Dever.pay(t, location, '支付失败');
 			});
 			/*
 			this.Dever.alert('拉起支付', 'none', function() {

+ 1 - 1
pages/dream/index.vue

@@ -32,7 +32,7 @@
 				</view>
 			</view>
 			<view v-if="buyState">
-				<buy :id="id" :bgcolor="fetch.button.bgcolor" :color="fetch.button.color" @hideBuy="hideBuy" @view="view"></buy>
+				<buy :id="id" :bgcolor="fetch.button.bgcolor" :color="fetch.button.color" :code="fetch.code" :name="fetch.info.name" @hideBuy="hideBuy" @view="view"></buy>
 			</view>
 			
 			<view v-if="rankingState">